@Override
  public void readFrom(StreamInput in) throws IOException {
    index = in.readUTF();
    shardId = in.readVInt();
    searchType = SearchType.fromId(in.readByte());
    numberOfShards = in.readVInt();
    if (in.readBoolean()) {
      scroll = readScroll(in);
    }

    source = in.readBytesReference();
    extraSource = in.readBytesReference();

    int typesSize = in.readVInt();
    if (typesSize > 0) {
      types = new String[typesSize];
      for (int i = 0; i < typesSize; i++) {
        types[i] = in.readUTF();
      }
    }
    int indicesSize = in.readVInt();
    if (indicesSize > 0) {
      filteringAliases = new String[indicesSize];
      for (int i = 0; i < indicesSize; i++) {
        filteringAliases[i] = in.readUTF();
      }
    } else {
      filteringAliases = null;
    }
    nowInMillis = in.readVLong();
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   index = in.readString();
   type = in.readString();
   id = in.readString();
   docVersion = in.readVLong();
   exists = in.readBoolean();
   artificial = in.readBoolean();
   tookInMillis = in.readVLong();
   if (in.readBoolean()) {
     headerRef = in.readBytesReference();
     termVectors = in.readBytesReference();
   }
 }
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    if (in.getVersion().before(Version.V_1_4_0)) {
      // term vector used to read & write the index twice, here and in the parent class
      in.readString();
    }
    type = in.readString();
    id = in.readString();

    if (in.getVersion().onOrAfter(Version.V_1_4_0)) {
      if (in.readBoolean()) {
        doc = in.readBytesReference();
      }
    }
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    long flags = in.readVLong();

    flagsEnum.clear();
    for (Flag flag : Flag.values()) {
      if ((flags & (1 << flag.ordinal())) != 0) {
        flagsEnum.add(flag);
      }
    }
    int numSelectedFields = in.readVInt();
    if (numSelectedFields > 0) {
      selectedFields = new HashSet<>();
      for (int i = 0; i < numSelectedFields; i++) {
        selectedFields.add(in.readString());
      }
    }
  }
Пример #4
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   sourceNodeId = in.readString();
   transferId = new UUID(in.readLong(), in.readLong());
   currentPos = in.readVInt();
   content = in.readBytesReference();
   isLast = in.readBoolean();
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   shardId = in.readVInt();
   preference = in.readOptionalString();
   int size = in.readVInt();
   items = new ArrayList<>(size);
   for (int i = 0; i < size; i++) {
     int slot = in.readVInt();
     OriginalIndices originalIndices = OriginalIndices.readOriginalIndices(in);
     PercolateShardRequest shardRequest =
         new PercolateShardRequest(new ShardId(index, shardId), originalIndices);
     shardRequest.documentType(in.readString());
     shardRequest.source(in.readBytesReference());
     shardRequest.docSource(in.readBytesReference());
     shardRequest.onlyCount(in.readBoolean());
     Item item = new Item(slot, shardRequest);
     items.add(item);
   }
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   type = in.readString();
   id = in.readString();
   routing = in.readOptionalString();
   preference = in.readOptionalString();
   source = in.readBytesReference();
   sourceUnsafe = false;
   filteringAlias = in.readStringArray();
   if (in.readBoolean()) {
     fields = in.readStringArray();
   }
 }
Пример #7
0
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    minScore = in.readFloat();
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    sourceUnsafe = false;
    source = in.readBytesReference();
    types = in.readStringArray();

    if (in.getVersion().onOrAfter(Version.V_1_4_0_Beta1)) {
      terminateAfter = in.readVInt();
    }
  }
Пример #8
0
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    type = in.readString();
    id = in.readString();
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    source = in.readBytesReference();
    filteringAlias = in.readStringArray();
    if (in.readBoolean()) {
      fields = in.readStringArray();
    }

    fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
    nowInMillis = in.readVLong();
  }
Пример #9
0
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    type = in.readSharedString();
    id = in.readOptionalString();
    routing = in.readOptionalString();
    parent = in.readOptionalString();
    timestamp = in.readOptionalString();
    ttl = in.readLong();
    source = in.readBytesReference();
    sourceUnsafe = false;

    opType = OpType.fromId(in.readByte());
    refresh = in.readBoolean();
    version = in.readLong();
    versionType = VersionType.fromValue(in.readByte());
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   recoveryId = in.readLong();
   shardId = ShardId.readShardId(in);
   String name = in.readString();
   position = in.readVLong();
   long length = in.readVLong();
   String checksum = in.readOptionalString();
   content = in.readBytesReference();
   Version writtenBy = null;
   if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_1_3_0)) {
     String versionString = in.readOptionalString();
     writtenBy = versionString == null ? null : Version.parseLeniently(versionString);
   }
   metaData = new StoreFileMetaData(name, length, checksum, writtenBy);
 }
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);

    sourceUnsafe = false;
    source = in.readBytesReference();

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

    explain = in.readBoolean();
  }
Пример #12
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   type = in.readOptionalString();
   id = in.readOptionalString();
   routing = in.readOptionalString();
   parent = in.readOptionalString();
   if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) {
     in.readOptionalString(); // timestamp
     in.readOptionalWriteable(TimeValue::new); // ttl
   }
   source = in.readBytesReference();
   opType = OpType.fromId(in.readByte());
   version = in.readLong();
   versionType = VersionType.fromValue(in.readByte());
   pipeline = in.readOptionalString();
   isRetry = in.readBoolean();
   autoGeneratedTimestamp = in.readLong();
 }
Пример #13
0
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    minScore = in.readFloat();

    querySource = in.readBytesReference();

    int typesSize = in.readVInt();
    if (typesSize > 0) {
      types = new String[typesSize];
      for (int i = 0; i < typesSize; i++) {
        types[i] = in.readString();
      }
    }
    int aliasesSize = in.readVInt();
    if (aliasesSize > 0) {
      filteringAliases = new String[aliasesSize];
      for (int i = 0; i < aliasesSize; i++) {
        filteringAliases[i] = in.readString();
      }
    }
    nowInMillis = in.readVLong();
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   percolatorTypeId = in.readByte();
   requestedSize = in.readVInt();
   count = in.readVLong();
   matches = new BytesRef[in.readVInt()];
   for (int i = 0; i < matches.length; i++) {
     matches[i] = in.readBytesRef();
   }
   scores = new float[in.readVInt()];
   for (int i = 0; i < scores.length; i++) {
     scores[i] = in.readFloat();
   }
   int size = in.readVInt();
   for (int i = 0; i < size; i++) {
     int mSize = in.readVInt();
     Map<String, HighlightField> fields = new HashMap<>();
     for (int j = 0; j < mSize; j++) {
       fields.put(in.readString(), HighlightField.readHighlightField(in));
     }
     hls.add(fields);
   }
   aggregations = InternalAggregations.readOptionalAggregations(in);
   if (in.readBoolean()) {
     int pipelineAggregatorsSize = in.readVInt();
     List<SiblingPipelineAggregator> pipelineAggregators =
         new ArrayList<>(pipelineAggregatorsSize);
     for (int i = 0; i < pipelineAggregatorsSize; i++) {
       BytesReference type = in.readBytesReference();
       PipelineAggregator pipelineAggregator =
           PipelineAggregatorStreams.stream(type).readResult(in);
       pipelineAggregators.add((SiblingPipelineAggregator) pipelineAggregator);
     }
     this.pipelineAggregators = pipelineAggregators;
   }
 }
Пример #15
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   index = in.readString();
   type = in.readOptionalString();
   id = in.readString();
   version = in.readLong();
   exists = in.readBoolean();
   if (exists) {
     source = in.readBytesReference();
     if (source.length() == 0) {
       source = null;
     }
     int size = in.readVInt();
     if (size == 0) {
       fields = emptyMap();
     } else {
       fields = new HashMap<>(size);
       for (int i = 0; i < size; i++) {
         GetField field = readGetField(in);
         fields.put(field.getName(), field);
       }
     }
   }
 }
Пример #16
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);
      }
    }
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   text = in.readBytesReference();
 }
 @Override
 public SearchSourceBuilder readFrom(StreamInput in) throws IOException {
   SearchSourceBuilder builder = new SearchSourceBuilder();
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<BytesReference> aggregations = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       aggregations.add(in.readBytesReference());
     }
     builder.aggregations = aggregations;
   }
   builder.explain = in.readOptionalBoolean();
   builder.fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
   boolean hasFieldDataFields = in.readBoolean();
   if (hasFieldDataFields) {
     int size = in.readVInt();
     List<String> fieldDataFields = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       fieldDataFields.add(in.readString());
     }
     builder.fieldDataFields = fieldDataFields;
   }
   boolean hasFieldNames = in.readBoolean();
   if (hasFieldNames) {
     int size = in.readVInt();
     List<String> fieldNames = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       fieldNames.add(in.readString());
     }
     builder.fieldNames = fieldNames;
   }
   builder.from = in.readVInt();
   if (in.readBoolean()) {
     builder.highlightBuilder = in.readBytesReference();
   }
   boolean hasIndexBoost = in.readBoolean();
   if (hasIndexBoost) {
     int size = in.readVInt();
     ObjectFloatHashMap<String> indexBoost = new ObjectFloatHashMap<String>(size);
     for (int i = 0; i < size; i++) {
       indexBoost.put(in.readString(), in.readFloat());
     }
     builder.indexBoost = indexBoost;
   }
   if (in.readBoolean()) {
     builder.innerHitsBuilder = in.readBytesReference();
   }
   if (in.readBoolean()) {
     builder.minScore = in.readFloat();
   }
   if (in.readBoolean()) {
     builder.postQueryBuilder = in.readQuery();
   }
   if (in.readBoolean()) {
     builder.queryBuilder = in.readQuery();
   }
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<BytesReference> rescoreBuilders = new ArrayList<>();
     for (int i = 0; i < size; i++) {
       rescoreBuilders.add(in.readBytesReference());
     }
     builder.rescoreBuilders = rescoreBuilders;
   }
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<ScriptField> scriptFields = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       scriptFields.add(ScriptField.PROTOTYPE.readFrom(in));
     }
     builder.scriptFields = scriptFields;
   }
   builder.size = in.readVInt();
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<BytesReference> sorts = new ArrayList<>();
     for (int i = 0; i < size; i++) {
       sorts.add(in.readBytesReference());
     }
     builder.sorts = sorts;
   }
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<String> stats = new ArrayList<>();
     for (int i = 0; i < size; i++) {
       stats.add(in.readString());
     }
     builder.stats = stats;
   }
   if (in.readBoolean()) {
     builder.suggestBuilder = in.readBytesReference();
   }
   builder.terminateAfter = in.readVInt();
   builder.timeoutInMillis = in.readLong();
   builder.trackScores = in.readBoolean();
   builder.version = in.readOptionalBoolean();
   if (in.readBoolean()) {
     builder.ext = in.readBytesReference();
   }
   return builder;
 }
Пример #19
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);
      }
    }
  }
 @Override
 protected DFB doReadFrom(StreamInput in) throws IOException {
   DFB decayFunctionBuilder = createFunctionBuilder(in.readString(), in.readBytesReference());
   decayFunctionBuilder.setMultiValueMode(MultiValueMode.readMultiValueModeFrom(in));
   return decayFunctionBuilder;
 }
 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();
 }