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

The following examples show how to use org.elasticsearch.common.io.stream.StreamOutput#writeFloat() . 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: ShardExistsRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeFloat(minScore);

    out.writeBytesReference(querySource);

    out.writeVInt(types.length);
    for (String type : types) {
        out.writeString(type);
    }
    if (filteringAliases != null) {
        out.writeVInt(filteringAliases.length);
        for (String alias : filteringAliases) {
            out.writeString(alias);
        }
    } else {
        out.writeVInt(0);
    }
    out.writeVLong(nowInMillis);
}
 
Example 2
Source File: FloatType.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeValueTo(StreamOutput out, Object v) throws IOException {
    out.writeBoolean(v == null);
    if (v != null) {
        out.writeFloat(((Number) v).floatValue());
    }
}
 
Example 3
Source File: SQLBaseResponse.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.writeStringArray(cols);
    out.writeBoolean(includeTypes);
    out.writeFloat(duration);
    if (includeTypes) {
        out.writeVInt(colTypes.length);
        for (DataType colType : colTypes) {
            DataTypes.toStream(colType, out);
        }
    }
}
 
Example 4
Source File: Suggest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeText(text);
    out.writeFloat(score);
    out.writeOptionalText(highlighted);
    out.writeOptionalBoolean(collateMatch);
}
 
Example 5
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static void writeScoreDoc(StreamOutput out, ScoreDoc scoreDoc) throws IOException {
    if (!scoreDoc.getClass().equals(ScoreDoc.class)) {
        throw new IllegalArgumentException("This method can only be used to serialize a ScoreDoc, not a " + scoreDoc.getClass());
    }
    out.writeVInt(scoreDoc.doc);
    out.writeFloat(scoreDoc.score);
}
 
Example 6
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException {
    out.writeBoolean(explanation.isMatch());
    out.writeString(explanation.getDescription());
    Explanation[] subExplanations = explanation.getDetails();
    out.writeVInt(subExplanations.length);
    for (Explanation subExp : subExplanations) {
        writeExplanation(out, subExp);
    }
    if (explanation.isMatch()) {
        out.writeFloat(explanation.getValue());
    }
}
 
Example 7
Source File: ExistsRequest.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.writeFloat(minScore);
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    out.writeBytesReference(source);
    out.writeStringArray(types);

}
 
Example 8
Source File: PercolateResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeText(id);
    out.writeText(index);
    out.writeFloat(score);
    if (hl != null) {
        out.writeVInt(hl.size());
        for (Map.Entry<String, HighlightField> entry : hl.entrySet()) {
            out.writeString(entry.getKey());
            entry.getValue().writeTo(out);
        }
    } else {
        out.writeVInt(0);
    }
}
 
Example 9
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 10
Source File: FloatType.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeValueTo(StreamOutput out, Float v) throws IOException {
    out.writeBoolean(v == null);
    if (v != null) {
        out.writeFloat(v);
    }
}
 
Example 11
Source File: Rounding.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    Rounding.Streams.write(rounding, out);
    out.writeFloat(factor);
}
 
Example 12
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 13
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.writeFloat(minValue);
    out.writeFloat(maxValue);
}
 
Example 14
Source File: StandardFeatureNormDefinition.java    From elasticsearch-learning-to-rank with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(this.featureName);
    out.writeFloat(this.mean);
    out.writeFloat(this.stdDeviation);
}
 
Example 15
Source File: MinMaxFeatureNormDefinition.java    From elasticsearch-learning-to-rank with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(this.featureName);
    out.writeFloat(this.minimum);
    out.writeFloat(this.maximum);
}