Пример #1
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   pid = in.readLong();
   version = in.readString();
   vmName = in.readString();
   vmVersion = in.readString();
   vmVendor = in.readString();
   startTime = in.readLong();
   inputArguments = new String[in.readInt()];
   for (int i = 0; i < inputArguments.length; i++) {
     inputArguments[i] = in.readString();
   }
   bootClassPath = in.readString();
   classPath = in.readString();
   systemProperties = new HashMap<>();
   int size = in.readInt();
   for (int i = 0; i < size; i++) {
     systemProperties.put(in.readString(), in.readString());
   }
   mem = new Mem();
   mem.readFrom(in);
   gcCollectors = in.readStringArray();
   memoryPools = in.readStringArray();
   useCompressedOops = in.readString();
 }
Пример #2
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   term = in.readString();
   startOffset = in.readInt();
   endOffset = in.readInt();
   position = in.readVInt();
   type = in.readOptionalString();
 }
Пример #3
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   numDocs = in.readInt();
   int n = in.readInt();
   termsList = new ArrayList<>();
   for (int i = 0; i < n; i++) {
     TermInfo ti = new TermInfo();
     ti.readFrom(in);
     termsList.add(ti);
   }
 }
Пример #4
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   if (in.getVersion().onOrAfter(version1)) {
     value2 = in.readInt();
   }
 }
Пример #5
0
  public static TopDocs readTopDocs(StreamInput in) throws IOException {
    if (!in.readBoolean()) {
      // no docs
      return null;
    }
    if (in.readBoolean()) {
      int totalHits = in.readVInt();
      float maxScore = in.readFloat();

      SortField[] fields = new SortField[in.readVInt()];
      for (int i = 0; i < fields.length; i++) {
        String field = null;
        if (in.readBoolean()) {
          field = in.readUTF();
        }
        fields[i] = new SortField(field, in.readVInt(), in.readBoolean());
      }

      FieldDoc[] fieldDocs = new FieldDoc[in.readVInt()];
      for (int i = 0; i < fieldDocs.length; i++) {
        Comparable[] cFields = new Comparable[in.readVInt()];
        for (int j = 0; j < cFields.length; j++) {
          byte type = in.readByte();
          if (type == 0) {
            cFields[j] = null;
          } else if (type == 1) {
            cFields[j] = in.readUTF();
          } else if (type == 2) {
            cFields[j] = in.readInt();
          } else if (type == 3) {
            cFields[j] = in.readLong();
          } else if (type == 4) {
            cFields[j] = in.readFloat();
          } else if (type == 5) {
            cFields[j] = in.readDouble();
          } else if (type == 6) {
            cFields[j] = in.readByte();
          } else if (type == 7) {
            cFields[j] = in.readShort();
          } else if (type == 8) {
            cFields[j] = in.readBoolean();
          } else {
            throw new IOException("Can't match type [" + type + "]");
          }
        }
        fieldDocs[i] = new FieldDoc(in.readVInt(), in.readFloat(), cFields);
      }
      return new TopFieldDocs(totalHits, fieldDocs, fields, maxScore);
    } else {
      int totalHits = in.readVInt();
      float maxScore = in.readFloat();

      ScoreDoc[] scoreDocs = new ScoreDoc[in.readVInt()];
      for (int i = 0; i < scoreDocs.length; i++) {
        scoreDocs[i] = new ScoreDoc(in.readVInt(), in.readFloat());
      }
      return new TopDocs(totalHits, scoreDocs, maxScore);
    }
  }
Пример #6
0
 public OsInfo(StreamInput in) throws IOException {
   this.refreshInterval = in.readLong();
   this.availableProcessors = in.readInt();
   this.allocatedProcessors = in.readInt();
   this.name = in.readOptionalString();
   this.arch = in.readOptionalString();
   this.version = in.readOptionalString();
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   int n = in.readInt();
   simple = new HashSet<String>();
   for (int i = 0; i < n; i++) {
     simple.add(in.readString());
   }
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   index = in.readString();
   shardId = in.readInt();
   timeout = TimeValue.readTimeValue(in);
   // no need to pass threading over the network, they are always false when coming throw a thread
   // pool
 }
 public static IndexTemplateMetaData readFrom(StreamInput in) throws IOException {
   Builder builder = new Builder(in.readUTF());
   builder.order(in.readInt());
   builder.template(in.readUTF());
   builder.settings(ImmutableSettings.readSettingsFromStream(in));
   int mappingsSize = in.readVInt();
   for (int i = 0; i < mappingsSize; i++) {
     builder.putMapping(in.readUTF(), CompressedString.readCompressedString(in));
   }
   return builder.build();
 }
Пример #10
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   MapBuilder<String, String> builder = MapBuilder.newMapBuilder();
   for (int i = in.readVInt(); i > 0; i--) {
     builder.put(in.readString(), in.readString());
   }
   userData = builder.immutableMap();
   generation = in.readLong();
   id = in.readOptionalString();
   numDocs = in.readInt();
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   states = new LinkedList<>();
   int size = in.readInt();
   for (int i = 0; i < size; i++) {
     KnapsackState ks = new KnapsackState();
     ks.readFrom(in);
     states.add(ks);
   }
 }
  @Override
  public void readFrom(StreamInput in) throws IOException {
    this.setIsPruned(in.readBoolean());
    int size = in.readInt();

    bytesUsed = Counter.newCounter();
    pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
    set = new BytesRefHash(pool);

    for (long i = 0; i < size; i++) {
      set.add(in.readBytesRef());
    }
  }
  @Override
  public void readFrom(StreamInput in) throws IOException {
    name = in.readUTF();
    comparatorType = ComparatorType.fromId(in.readByte());
    requiredSize = in.readVInt();
    missing = in.readVLong();

    int size = in.readVInt();
    entries = new ArrayList<IntEntry>(size);
    for (int i = 0; i < size; i++) {
      entries.add(new IntEntry(in.readInt(), in.readVInt()));
    }
  }
 @Override
 protected SimpleQueryStringBuilder doReadFrom(StreamInput in) throws IOException {
   SimpleQueryStringBuilder result = new SimpleQueryStringBuilder(in.readString());
   int size = in.readInt();
   Map<String, Float> fields = new HashMap<>();
   for (int i = 0; i < size; i++) {
     String field = in.readString();
     Float weight = in.readFloat();
     fields.put(field, weight);
   }
   result.fieldsAndWeights.putAll(fields);
   result.flags = in.readInt();
   result.analyzer = in.readOptionalString();
   result.defaultOperator = Operator.readOperatorFrom(in);
   result.settings.lowercaseExpandedTerms(in.readBoolean());
   result.settings.lenient(in.readBoolean());
   result.settings.analyzeWildcard(in.readBoolean());
   String localeStr = in.readString();
   result.settings.locale(Locale.forLanguageTag(localeStr));
   result.minimumShouldMatch = in.readOptionalString();
   return result;
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   cause = in.readUTF();
   name = in.readUTF();
   template = in.readUTF();
   order = in.readInt();
   create = in.readBoolean();
   settings = readSettingsFromStream(in);
   timeout = readTimeValue(in);
   int size = in.readVInt();
   for (int i = 0; i < size; i++) {
     mappings.put(in.readUTF(), in.readUTF());
   }
 }
Пример #16
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   name = in.readString();
   type = in.readString();
   min = in.readInt();
   max = in.readInt();
   if (in.readBoolean()) {
     keepAlive = TimeValue.readTimeValue(in);
   }
   if (in.readBoolean()) {
     queueSize = SizeValue.readSizeValue(in);
   }
   in.readBoolean(); // here to conform with removed waitTime
   in.readBoolean(); // here to conform with removed rejected setting
   in.readBoolean(); // here to conform with queue type
 }
 @Override
 protected void doReadFrom(StreamInput in) throws IOException {
   valueFormatter = ValueFormatterStreams.readOptional(in);
   keys = new double[in.readInt()];
   for (int i = 0; i < keys.length; ++i) {
     keys[i] = in.readDouble();
   }
   long minBarForHighestToLowestValueRatio = in.readLong();
   ByteBuffer stateBuffer = ByteBuffer.wrap(in.readByteArray());
   try {
     state =
         DoubleHistogram.decodeFromCompressedByteBuffer(
             stateBuffer, minBarForHighestToLowestValueRatio);
   } catch (DataFormatException e) {
     throw new IOException("Failed to decode DoubleHistogram for aggregation [" + name + "]", e);
   }
   keyed = in.readBoolean();
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   cause = in.readString();
   name = in.readString();
   template = in.readString();
   order = in.readInt();
   create = in.readBoolean();
   settings = readSettingsFromStream(in);
   timeout = readTimeValue(in);
   int size = in.readVInt();
   for (int i = 0; i < size; i++) {
     mappings.put(in.readString(), in.readString());
   }
   int customSize = in.readVInt();
   for (int i = 0; i < customSize; i++) {
     String type = in.readString();
     IndexMetaData.Custom customIndexMetaData = IndexMetaData.lookupFactorySafe(type).readFrom(in);
     customs.put(type, customIndexMetaData);
   }
 }
 public void testSimpleStreams() throws Exception {
   assumeTrue("requires a 64-bit JRE ... ?!", Constants.JRE_IS_64BIT);
   BytesStreamOutput out = new BytesStreamOutput();
   out.writeBoolean(false);
   out.writeByte((byte) 1);
   out.writeShort((short) -1);
   out.writeInt(-1);
   out.writeVInt(2);
   out.writeLong(-3);
   out.writeVLong(4);
   out.writeOptionalLong(11234234L);
   out.writeFloat(1.1f);
   out.writeDouble(2.2);
   int[] intArray = {1, 2, 3};
   out.writeGenericValue(intArray);
   int[] vIntArray = {4, 5, 6};
   out.writeVIntArray(vIntArray);
   long[] longArray = {1, 2, 3};
   out.writeGenericValue(longArray);
   long[] vLongArray = {4, 5, 6};
   out.writeVLongArray(vLongArray);
   float[] floatArray = {1.1f, 2.2f, 3.3f};
   out.writeGenericValue(floatArray);
   double[] doubleArray = {1.1, 2.2, 3.3};
   out.writeGenericValue(doubleArray);
   out.writeString("hello");
   out.writeString("goodbye");
   out.writeGenericValue(BytesRefs.toBytesRef("bytesref"));
   out.writeStringArray(new String[] {"a", "b", "cat"});
   out.writeBytesReference(new BytesArray("test"));
   out.writeOptionalBytesReference(new BytesArray("test"));
   out.writeOptionalDouble(null);
   out.writeOptionalDouble(1.2);
   out.writeTimeZone(DateTimeZone.forID("CET"));
   out.writeOptionalTimeZone(DateTimeZone.getDefault());
   out.writeOptionalTimeZone(null);
   final byte[] bytes = BytesReference.toBytes(out.bytes());
   StreamInput in = StreamInput.wrap(BytesReference.toBytes(out.bytes()));
   assertEquals(in.available(), bytes.length);
   assertThat(in.readBoolean(), equalTo(false));
   assertThat(in.readByte(), equalTo((byte) 1));
   assertThat(in.readShort(), equalTo((short) -1));
   assertThat(in.readInt(), equalTo(-1));
   assertThat(in.readVInt(), equalTo(2));
   assertThat(in.readLong(), equalTo(-3L));
   assertThat(in.readVLong(), equalTo(4L));
   assertThat(in.readOptionalLong(), equalTo(11234234L));
   assertThat((double) in.readFloat(), closeTo(1.1, 0.0001));
   assertThat(in.readDouble(), closeTo(2.2, 0.0001));
   assertThat(in.readGenericValue(), equalTo((Object) intArray));
   assertThat(in.readVIntArray(), equalTo(vIntArray));
   assertThat(in.readGenericValue(), equalTo((Object) longArray));
   assertThat(in.readVLongArray(), equalTo(vLongArray));
   assertThat(in.readGenericValue(), equalTo((Object) floatArray));
   assertThat(in.readGenericValue(), equalTo((Object) doubleArray));
   assertThat(in.readString(), equalTo("hello"));
   assertThat(in.readString(), equalTo("goodbye"));
   assertThat(in.readGenericValue(), equalTo((Object) BytesRefs.toBytesRef("bytesref")));
   assertThat(in.readStringArray(), equalTo(new String[] {"a", "b", "cat"}));
   assertThat(in.readBytesReference(), equalTo(new BytesArray("test")));
   assertThat(in.readOptionalBytesReference(), equalTo(new BytesArray("test")));
   assertNull(in.readOptionalDouble());
   assertThat(in.readOptionalDouble(), closeTo(1.2, 0.0001));
   assertEquals(DateTimeZone.forID("CET"), in.readTimeZone());
   assertEquals(DateTimeZone.getDefault(), in.readOptionalTimeZone());
   assertNull(in.readOptionalTimeZone());
   assertEquals(0, in.available());
   in.close();
   out.close();
 }
Пример #20
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   field = in.readOptionalText();
   offset = in.readInt();
   child = in.readOptionalStreamable(new InternalNestedIdentity());
 }
Пример #21
0
  public void readFrom(StreamInput in, InternalSearchHits.StreamContext context)
      throws IOException {
    score = in.readFloat();
    id = in.readText();
    type = in.readText();
    nestedIdentity = in.readOptionalStreamable(new InternalNestedIdentity());
    version = in.readLong();
    source = in.readBytesReference();
    if (source.length() == 0) {
      source = null;
    }
    if (in.readBoolean()) {
      explanation = readExplanation(in);
    }
    int size = in.readVInt();
    if (size == 0) {
      fields = ImmutableMap.of();
    } else if (size == 1) {
      SearchHitField hitField = readSearchHitField(in);
      fields = ImmutableMap.of(hitField.name(), hitField);
    } else if (size == 2) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2);
    } else if (size == 3) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      SearchHitField hitField3 = readSearchHitField(in);
      fields =
          ImmutableMap.of(
              hitField1.name(),
              hitField1,
              hitField2.name(),
              hitField2,
              hitField3.name(),
              hitField3);
    } else if (size == 4) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      SearchHitField hitField3 = readSearchHitField(in);
      SearchHitField hitField4 = readSearchHitField(in);
      fields =
          ImmutableMap.of(
              hitField1.name(),
              hitField1,
              hitField2.name(),
              hitField2,
              hitField3.name(),
              hitField3,
              hitField4.name(),
              hitField4);
    } else if (size == 5) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      SearchHitField hitField3 = readSearchHitField(in);
      SearchHitField hitField4 = readSearchHitField(in);
      SearchHitField hitField5 = readSearchHitField(in);
      fields =
          ImmutableMap.of(
              hitField1.name(),
              hitField1,
              hitField2.name(),
              hitField2,
              hitField3.name(),
              hitField3,
              hitField4.name(),
              hitField4,
              hitField5.name(),
              hitField5);
    } else {
      ImmutableMap.Builder<String, SearchHitField> builder = ImmutableMap.builder();
      for (int i = 0; i < size; i++) {
        SearchHitField hitField = readSearchHitField(in);
        builder.put(hitField.name(), hitField);
      }
      fields = builder.build();
    }

    size = in.readVInt();
    if (size == 0) {
      highlightFields = ImmutableMap.of();
    } else if (size == 1) {
      HighlightField field = readHighlightField(in);
      highlightFields = ImmutableMap.of(field.name(), field);
    } else if (size == 2) {
      HighlightField field1 = readHighlightField(in);
      HighlightField field2 = readHighlightField(in);
      highlightFields = ImmutableMap.of(field1.name(), field1, field2.name(), field2);
    } else if (size == 3) {
      HighlightField field1 = readHighlightField(in);
      HighlightField field2 = readHighlightField(in);
      HighlightField field3 = readHighlightField(in);
      highlightFields =
          ImmutableMap.of(field1.name(), field1, field2.name(), field2, field3.name(), field3);
    } else if (size == 4) {
      HighlightField field1 = readHighlightField(in);
      HighlightField field2 = readHighlightField(in);
      HighlightField field3 = readHighlightField(in);
      HighlightField field4 = readHighlightField(in);
      highlightFields =
          ImmutableMap.of(
              field1.name(),
              field1,
              field2.name(),
              field2,
              field3.name(),
              field3,
              field4.name(),
              field4);
    } else {
      ImmutableMap.Builder<String, HighlightField> builder = ImmutableMap.builder();
      for (int i = 0; i < size; i++) {
        HighlightField field = readHighlightField(in);
        builder.put(field.name(), field);
      }
      highlightFields = builder.build();
    }

    size = in.readVInt();
    if (size > 0) {
      sortValues = new Object[size];
      for (int i = 0; i < sortValues.length; i++) {
        byte type = in.readByte();
        if (type == 0) {
          sortValues[i] = null;
        } else if (type == 1) {
          sortValues[i] = in.readString();
        } else if (type == 2) {
          sortValues[i] = in.readInt();
        } else if (type == 3) {
          sortValues[i] = in.readLong();
        } else if (type == 4) {
          sortValues[i] = in.readFloat();
        } else if (type == 5) {
          sortValues[i] = in.readDouble();
        } else if (type == 6) {
          sortValues[i] = in.readByte();
        } else if (type == 7) {
          sortValues[i] = in.readShort();
        } else if (type == 8) {
          sortValues[i] = in.readBoolean();
        } else if (type == 9) {
          sortValues[i] = in.readText();
        } else {
          throw new IOException("Can't match type [" + type + "]");
        }
      }
    }

    size = in.readVInt();
    if (size > 0) {
      matchedQueries = new String[size];
      for (int i = 0; i < size; i++) {
        matchedQueries[i] = in.readString();
      }
    }

    if (context.streamShardTarget() == InternalSearchHits.StreamContext.ShardTargetType.STREAM) {
      if (in.readBoolean()) {
        shard = readSearchShardTarget(in);
      }
    } else if (context.streamShardTarget()
        == InternalSearchHits.StreamContext.ShardTargetType.LOOKUP) {
      int lookupId = in.readVInt();
      if (lookupId > 0) {
        shard = context.handleShardLookup().get(lookupId);
      }
    }

    size = in.readVInt();
    if (size > 0) {
      innerHits = new HashMap<>(size);
      for (int i = 0; i < size; i++) {
        String key = in.readString();
        InternalSearchHits value =
            InternalSearchHits.readSearchHits(
                in,
                InternalSearchHits.streamContext()
                    .streamShardTarget(InternalSearchHits.StreamContext.ShardTargetType.NO_STREAM));
        innerHits.put(key, value);
      }
    }
  }
Пример #22
0
  public void readFrom(StreamInput in, InternalSearchHits.StreamContext context)
      throws IOException {
    score = in.readFloat();
    id = in.readText();
    type = in.readText();
    nestedIdentity = in.readOptionalStreamable(InternalNestedIdentity::new);
    version = in.readLong();
    source = in.readBytesReference();
    if (source.length() == 0) {
      source = null;
    }
    if (in.readBoolean()) {
      explanation = readExplanation(in);
    }
    int size = in.readVInt();
    if (size == 0) {
      fields = emptyMap();
    } else if (size == 1) {
      SearchHitField hitField = readSearchHitField(in);
      fields = singletonMap(hitField.name(), hitField);
    } else {
      Map<String, SearchHitField> fields = new HashMap<>();
      for (int i = 0; i < size; i++) {
        SearchHitField hitField = readSearchHitField(in);
        fields.put(hitField.name(), hitField);
      }
      this.fields = unmodifiableMap(fields);
    }

    size = in.readVInt();
    if (size == 0) {
      highlightFields = emptyMap();
    } else if (size == 1) {
      HighlightField field = readHighlightField(in);
      highlightFields = singletonMap(field.name(), field);
    } else {
      Map<String, HighlightField> highlightFields = new HashMap<>();
      for (int i = 0; i < size; i++) {
        HighlightField field = readHighlightField(in);
        highlightFields.put(field.name(), field);
      }
      this.highlightFields = unmodifiableMap(highlightFields);
    }

    size = in.readVInt();
    if (size > 0) {
      sortValues = new Object[size];
      for (int i = 0; i < sortValues.length; i++) {
        byte type = in.readByte();
        if (type == 0) {
          sortValues[i] = null;
        } else if (type == 1) {
          sortValues[i] = in.readString();
        } else if (type == 2) {
          sortValues[i] = in.readInt();
        } else if (type == 3) {
          sortValues[i] = in.readLong();
        } else if (type == 4) {
          sortValues[i] = in.readFloat();
        } else if (type == 5) {
          sortValues[i] = in.readDouble();
        } else if (type == 6) {
          sortValues[i] = in.readByte();
        } else if (type == 7) {
          sortValues[i] = in.readShort();
        } else if (type == 8) {
          sortValues[i] = in.readBoolean();
        } else {
          throw new IOException("Can't match type [" + type + "]");
        }
      }
    }

    size = in.readVInt();
    if (size > 0) {
      matchedQueries = new String[size];
      for (int i = 0; i < size; i++) {
        matchedQueries[i] = in.readString();
      }
    }

    if (context.streamShardTarget() == ShardTargetType.STREAM) {
      if (in.readBoolean()) {
        shard = new SearchShardTarget(in);
      }
    } else if (context.streamShardTarget() == ShardTargetType.LOOKUP) {
      int lookupId = in.readVInt();
      if (lookupId > 0) {
        shard = context.handleShardLookup().get(lookupId);
      }
    }

    size = in.readVInt();
    if (size > 0) {
      innerHits = new HashMap<>(size);
      for (int i = 0; i < size; i++) {
        String key = in.readString();
        ShardTargetType shardTarget = context.streamShardTarget();
        InternalSearchHits value =
            InternalSearchHits.readSearchHits(
                in, context.streamShardTarget(ShardTargetType.NO_STREAM));
        context.streamShardTarget(shardTarget);
        innerHits.put(key, value);
      }
    }
  }
Пример #23
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   value1 = in.readInt();
 }