Java Code Examples for org.elasticsearch.common.io.stream.StreamOutput#writeBytesRef()

The following examples show how to use org.elasticsearch.common.io.stream.StreamOutput#writeBytesRef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AggregatedDfs.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(final StreamOutput out) throws IOException {
    out.writeVInt(termStatistics.size());
    
    for (ObjectObjectCursor<Term, TermStatistics> c : termStatistics()) {
        Term term = (Term) c.key;
        out.writeString(term.field());
        out.writeBytesRef(term.bytes());
        TermStatistics stats = (TermStatistics) c.value;
        out.writeBytesRef(stats.term());
        out.writeVLong(stats.docFreq());
        out.writeVLong(DfsSearchResult.addOne(stats.totalTermFreq()));
    }

    DfsSearchResult.writeFieldStats(out, fieldStatistics);
    out.writeVLong(maxDoc);
}
 
Example 2
Source File: TermsByQueryResponse.java    From siren-join with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Serialize
 *
 * @param out the output
 * @throws IOException
 */
@Override
public void writeTo(StreamOutput out) throws IOException {
  super.writeTo(out);

  // Encode flag
  out.writeBoolean(isPruned);
  // Encode size
  out.writeVInt(size);
  // Encode type of encoding
  out.writeVInt(termsEncoding.ordinal());
  // Encode terms
  out.writeBytesRef(encodedTerms);
  // Release terms
  encodedTerms = null;
}
 
Example 3
Source File: SignificantStringTerms.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeBytesRef(termBytes);
    out.writeVLong(subsetDf);
    out.writeVLong(supersetDf);
    out.writeDouble(getSignificanceScore());
    aggregations.writeTo(out);
}
 
Example 4
Source File: StringTerms.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeBytesRef(termBytes);
    out.writeVLong(getDocCount());
    if (showDocCountError) {
        out.writeLong(docCountError);
    }
    aggregations.writeTo(out);
}
 
Example 5
Source File: DfsSearchResult.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeLong(id);
    out.writeVInt(terms.length);
    for (Term term : terms) {
        out.writeString(term.field());
        out.writeBytesRef(term.bytes());
    }
    writeTermStats(out, termStatistics);
    writeFieldStats(out, fieldStatistics);
    out.writeVInt(maxDoc);
}
 
Example 6
Source File: StoreFileMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(name);
    out.writeVLong(length);
    out.writeOptionalString(checksum);
    out.writeOptionalString(writtenBy == null ? null : writtenBy.toString());
    out.writeBytesRef(hash);
}
 
Example 7
Source File: PercolateShardResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeByte(percolatorTypeId);
    out.writeVLong(requestedSize);
    out.writeVLong(count);
    out.writeVInt(matches.length);
    for (BytesRef match : matches) {
        out.writeBytesRef(match);
    }
    out.writeVLong(scores.length);
    for (float score : scores) {
        out.writeFloat(score);
    }
    out.writeVInt(hls.size());
    for (Map<String, HighlightField> hl : hls) {
        out.writeVInt(hl.size());
        for (Map.Entry<String, HighlightField> entry : hl.entrySet()) {
            out.writeString(entry.getKey());
            entry.getValue().writeTo(out);
        }
    }
    out.writeOptionalStreamable(aggregations);
    if (pipelineAggregators == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeVInt(pipelineAggregators.size());
        for (PipelineAggregator pipelineAggregator : pipelineAggregators) {
            out.writeBytesReference(pipelineAggregator.type().stream());
            pipelineAggregator.writeTo(out);
        }
    }
}
 
Example 8
Source File: BytesRefTermsSet.java    From siren-join with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
  // Encode flag
  out.writeBoolean(this.isPruned());

  // Encode size of list
  out.writeInt(set.size());

  // Encode BytesRefs
  BytesRef reusable = new BytesRef();
  for (int i = 0; i < this.set.size(); i++) {
    this.set.get(i, reusable);
    out.writeBytesRef(reusable);
  }
}
 
Example 9
Source File: InternalDateHierarchy.java    From elasticsearch-aggregation-pathhierarchy with MIT License 5 votes vote down vote up
/**
 * Write to a stream.
 */
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeBytesRef(key);
    out.writeString(name);
    out.writeLong(docCount);
    aggregations.writeTo(out);
    out.writeInt(level);
    out.writeInt(paths.length);
    for (String path: paths) {
        out.writeString(path);
    }
}
 
Example 10
Source File: InternalPathHierarchy.java    From elasticsearch-aggregation-pathhierarchy with MIT License 5 votes vote down vote up
/**
 * Write to a stream.
 */
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeBytesRef(termBytes);
    out.writeLong(docCount);
    aggregations.writeTo(out);
    out.writeInt(level);
    out.writeInt(minDepth);
    out.writeString(basename);
    out.writeInt(paths.length);
    for (String path: paths) {
        out.writeString(path);
    }
}
 
Example 11
Source File: InternalPathHierarchy.java    From elasticsearch-aggregation-pathhierarchy with MIT License 5 votes vote down vote up
/**
 * Write to a stream.
 */
@Override
protected void doWriteTo(StreamOutput out) throws IOException {
    InternalOrder.Streams.writeOrder(order, out);
    out.writeVLong(minDocCount);
    writeSize(requiredSize, out);
    writeSize(shardSize, out);
    out.writeVLong(otherHierarchyNodes);
    out.writeBytesRef(separator);
    out.writeInt(buckets.size());
    for (InternalBucket bucket: buckets) {
        bucket.writeTo(out);
    }
}
 
Example 12
Source File: InternalGeoShape.java    From elasticsearch-plugin-geoshape with MIT License 5 votes vote down vote up
/**
 * Write to a stream.
 */
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeBytesRef(wkb);
    out.writeString(wkbHash);
    out.writeString(realType);
    out.writeDouble(area);
    out.writeLong(docCount);
    aggregations.writeTo(out);
}
 
Example 13
Source File: Translog.java    From crate with Apache License 2.0 5 votes vote down vote up
private void write(final StreamOutput out) throws IOException {
    final int format = out.getVersion().onOrAfter(Version.V_4_0_0) ? SERIALIZATION_FORMAT : FORMAT_6_0;
    out.writeVInt(format);
    out.writeString(type);
    out.writeString(id);
    out.writeString(uid.field());
    out.writeBytesRef(uid.bytes());
    out.writeLong(version);
    if (format < FORMAT_NO_VERSION_TYPE) {
        out.writeByte(VersionType.EXTERNAL.getValue());
    }
    out.writeLong(seqNo);
    out.writeLong(primaryTerm);
}
 
Example 14
Source File: StoreFileMetaData.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(name);
    out.writeVLong(length);
    out.writeString(checksum);
    out.writeString(writtenBy.toString());
    out.writeBytesRef(hash);
}
 
Example 15
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static void writeFieldDoc(StreamOutput out, FieldDoc fieldDoc) throws IOException {
    out.writeVInt(fieldDoc.fields.length);
    for (Object field : fieldDoc.fields) {
        if (field == null) {
            out.writeByte((byte) 0);
        } else {
            Class type = field.getClass();
            if (type == String.class) {
                out.writeByte((byte) 1);
                out.writeString((String) field);
            } else if (type == Integer.class) {
                out.writeByte((byte) 2);
                out.writeInt((Integer) field);
            } else if (type == Long.class) {
                out.writeByte((byte) 3);
                out.writeLong((Long) field);
            } else if (type == Float.class) {
                out.writeByte((byte) 4);
                out.writeFloat((Float) field);
            } else if (type == Double.class) {
                out.writeByte((byte) 5);
                out.writeDouble((Double) field);
            } else if (type == Byte.class) {
                out.writeByte((byte) 6);
                out.writeByte((Byte) field);
            } else if (type == Short.class) {
                out.writeByte((byte) 7);
                out.writeShort((Short) field);
            } else if (type == Boolean.class) {
                out.writeByte((byte) 8);
                out.writeBoolean((Boolean) field);
            } else if (type == BytesRef.class) {
                out.writeByte((byte) 9);
                out.writeBytesRef((BytesRef) field);
            } else {
                throw new IOException("Can't handle sort field value of type [" + type + "]");
            }
        }
    }
    out.writeVInt(fieldDoc.doc);
    out.writeFloat(fieldDoc.score);
}
 
Example 16
Source File: FieldStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeBytesRef(minValue);
    out.writeBytesRef(maxValue);
}