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

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

    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);
    }
}
 
Example 2
Source File: Translog.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(SERIALIZATION_FORMAT);
    out.writeBytesReference(source);
    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);
    }
}
 
Example 3
Source File: Translog.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(SERIALIZATION_FORMAT);
    out.writeString(id);
    out.writeString(type);
    out.writeBytesReference(source);
    if (routing == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeString(routing);
    }
    if (parent == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeString(parent);
    }
    out.writeLong(version);
    out.writeLong(timestamp);
    out.writeLong(ttl);
    out.writeByte(versionType.getValue());
}
 
Example 4
Source File: ExplainRequest.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.writeString(type);
    out.writeString(id);
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    out.writeBytesReference(source);
    out.writeStringArray(filteringAlias);
    if (fields != null) {
        out.writeBoolean(true);
        out.writeStringArray(fields);
    } else {
        out.writeBoolean(false);
    }

    FetchSourceContext.optionalWriteToStream(fetchSourceContext, out);
    out.writeVLong(nowInMillis);
}
 
Example 5
Source File: GetFieldMappingsResponse.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.writeVInt(mappings.size());
    for (Map.Entry<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
        out.writeString(indexEntry.getKey());
        out.writeVInt(indexEntry.getValue().size());
        for (Map.Entry<String, ImmutableMap<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
            out.writeString(typeEntry.getKey());
            out.writeVInt(typeEntry.getValue().size());
            for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
                out.writeString(fieldEntry.getKey());
                FieldMappingMetaData fieldMapping = fieldEntry.getValue();
                out.writeString(fieldMapping.fullName());
                out.writeBytesReference(fieldMapping.source);
            }
        }
    }
}
 
Example 6
Source File: PercolateRequest.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.writeVLong(startTime);
    out.writeString(documentType);
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    out.writeBytesReference(source);
    out.writeBytesReference(docSource);
    if (getRequest != null) {
        out.writeBoolean(true);
        getRequest.writeTo(out);
    } else {
        out.writeBoolean(false);
    }
    out.writeBoolean(onlyCount);
}
 
Example 7
Source File: PutBlobHeadChunkRequest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeLong(transferId.getMostSignificantBits());
    out.writeLong(transferId.getLeastSignificantBits());
    out.writeBytesReference(content);
}
 
Example 8
Source File: PutChunkReplicaRequest.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.writeString(sourceNodeId);
    out.writeLong(transferId.getMostSignificantBits());
    out.writeLong(transferId.getLeastSignificantBits());
    out.writeVLong(currentPos);
    out.writeBytesReference(content);
    out.writeBoolean(isLast);
}
 
Example 9
Source File: ShardUpsertRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(id);
    if (updateAssignments != null) {
        out.writeVInt(updateAssignments.length);
        for (Symbol updateAssignment : updateAssignments) {
            Symbol.toStream(updateAssignment, out);
        }
    } else {
        out.writeVInt(0);
    }
    // Stream References
    if (insertValues != null) {
        out.writeVInt(insertValues.length);
        for (int i = 0; i < insertValues.length; i++) {
            insertValuesStreamer[i].writeValueTo(out, insertValues[i]);
        }
    } else {
        out.writeVInt(0);
    }

    Version.writeVersion(Version.fromId((int) version), out);
    out.writeByte(versionType.getValue());
    out.writeByte(opType.id());
    boolean sourceAvailable = source != null;
    out.writeBoolean(sourceAvailable);
    if (sourceAvailable) {
        out.writeBytesReference(source);
    }
}
 
Example 10
Source File: RecoveryFileChunkRequest.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(recoveryId);
    shardId.writeTo(out);
    out.writeString(metaData.name());
    out.writeVLong(position);
    out.writeVLong(metaData.length());
    out.writeOptionalString(metaData.checksum());
    out.writeBytesReference(content);
    out.writeOptionalString(metaData.writtenBy() == null ? null : metaData.writtenBy().toString());
    out.writeBoolean(lastChunk);
    out.writeVInt(totalTranslogOps);
    out.writeLong(sourceThrottleTimeInNanos);
}
 
Example 11
Source File: DeployRequest.java    From elasticsearch-gatherer with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    if (name == null) {
        throw new IOException("no name was given for deploy request");
    }
    if (ref == null) {
        throw new IOException("no valid path was given for deploy request");
    }
    out.writeString(name);
    out.writeString(path);
    out.writeBytesReference(ref);
}
 
Example 12
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(id);
    out.writeString(type);
    out.writeBytesReference(source);
    out.writeOptionalString(routing);
    out.writeLong(version);
    if (format < FORMAT_NO_VERSION_TYPE) {
        out.writeByte(VersionType.EXTERNAL.getValue());
    }
    out.writeLong(autoGeneratedIdTimestamp);
    out.writeLong(seqNo);
    out.writeLong(primaryTerm);
}
 
Example 13
Source File: SuggestRequest.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.writeOptionalString(routing);
    out.writeOptionalString(preference);
    out.writeBytesReference(suggestSource);
}
 
Example 14
Source File: TermVectorsRequest.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.writeString(type);
    out.writeString(id);

    out.writeBoolean(doc != null);
    if (doc != null) {
        out.writeBytesReference(doc);
    }
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    long longFlags = 0;
    for (Flag flag : flagsEnum) {
        longFlags |= (1 << flag.ordinal());
    }
    out.writeVLong(longFlags);
    if (selectedFields != null) {
        out.writeVInt(selectedFields.size());
        for (String selectedField : selectedFields) {
            out.writeString(selectedField);
        }
    } else {
        out.writeVInt(0);
    }
    out.writeBoolean(perFieldAnalyzer != null);
    if (perFieldAnalyzer != null) {
        out.writeGenericValue(perFieldAnalyzer);
    }
    out.writeBoolean(filterSettings != null);
    if (filterSettings != null) {
        filterSettings.writeTo(out);
    }
    out.writeBoolean(realtime());
    out.writeByte(versionType.getValue());
    out.writeLong(version);
}
 
Example 15
Source File: ShardSearchLocalRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
protected void innerWriteTo(StreamOutput out, boolean asKey) throws IOException {
    out.writeString(index);
    out.writeVInt(shardId);
    out.writeByte(searchType.id());
    if (!asKey) {
        out.writeVInt(numberOfShards);
    }
    if (scroll == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        scroll.writeTo(out);
    }
    out.writeBytesReference(source);
    out.writeBytesReference(extraSource);
    out.writeStringArray(types);
    out.writeStringArrayNullable(filteringAliases);
    if (!asKey) {
        out.writeVLong(nowInMillis);
    }

    out.writeBytesReference(templateSource);
    boolean hasTemplate = template != null;
    out.writeBoolean(hasTemplate);
    if (hasTemplate) {
        template.writeTo(out);
    }
    out.writeOptionalBoolean(requestCache);
}
 
Example 16
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 17
Source File: StreamBucket.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public void writeToStream(StreamOutput output) throws IOException {
    output.writeVInt(size);
    if (size > 0) {
        output.writeBytesReference(out.bytes());
    }
}
 
Example 18
Source File: CompletionSuggestion.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.writeBytesReference(payload);
}
 
Example 19
Source File: BytesTransportRequest.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeBytesReference(bytes);
}
 
Example 20
Source File: TermsByQueryRequest.java    From siren-join with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Serialize
 *
 * @param out the output
 * @throws IOException
 */
@Override
public void writeTo(StreamOutput out) throws IOException {
  super.writeTo(out);

  out.writeOptionalString(routing);
  out.writeOptionalString(preference);

  if (querySource != null) {
    out.writeBoolean(true);
    out.writeBytesReference(querySource);
  } else {
    out.writeBoolean(false);
  }

  if (types == null) {
    out.writeBoolean(false);
  } else {
    out.writeBoolean(true);
    out.writeStringArray(types);
  }

  out.writeString(field);
  out.writeVLong(nowInMillis);

  if (ordering == null) {
    out.writeBoolean(false);
  } else {
    out.writeBoolean(true);
    out.writeVInt(ordering.ordinal());
  }

  if (maxTermsPerShard == null) {
    out.writeBoolean(false);
  } else {
    out.writeBoolean(true);
    out.writeVInt(maxTermsPerShard);
  }

  if (termsEncoding == null) {
    out.writeBoolean(false);
  } else {
    out.writeBoolean(true);
    out.writeVInt(termsEncoding.ordinal());
  }

  if (expectedTerms == null) {
    out.writeBoolean(false);
  }
  else {
    out.writeBoolean(true);
    out.writeVLong(expectedTerms);
  }
}