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

The following examples show how to use org.elasticsearch.common.io.stream.StreamOutput#writeInt() . 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: NodeFetchRequest.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.writeLong(jobId.getMostSignificantBits());
    out.writeLong(jobId.getLeastSignificantBits());
    out.writeVInt(fetchPhaseId);
    if (toFetch == null) {
        out.writeVInt(0);
    } else {
        out.writeVInt(toFetch.size());
        for (IntObjectCursor<IntContainer> toFetchCursor : toFetch) {
            out.writeVInt(toFetchCursor.key);
            out.writeVInt(toFetchCursor.value.size());
            for (IntCursor docCursor : toFetchCursor.value) {
                out.writeInt(docCursor.value);
            }
        }
    }
}
 
Example 2
Source File: Translog.java    From crate with Apache License 2.0 6 votes vote down vote up
/**
 * Writes all operations in the given iterable to the given output stream including the size of the array
 * use {@link #readOperations(StreamInput, String)} to read it back.
 */
public static void writeOperations(StreamOutput outStream, List<Operation> toWrite) throws IOException {
    final ReleasableBytesStreamOutput out = new ReleasableBytesStreamOutput(BigArrays.NON_RECYCLING_INSTANCE);
    try {
        outStream.writeInt(toWrite.size());
        final BufferedChecksumStreamOutput checksumStreamOutput = new BufferedChecksumStreamOutput(out);
        for (Operation op : toWrite) {
            out.reset();
            final long start = out.position();
            out.skip(Integer.BYTES);
            writeOperationNoSize(checksumStreamOutput, op);
            long end = out.position();
            int operationSize = (int) (out.position() - Integer.BYTES - start);
            out.seek(start);
            out.writeInt(operationSize);
            out.seek(end);
            ReleasablePagedBytesReference bytes = out.bytes();
            bytes.writeTo(outStream);
        }
    } finally {
        Releasables.close(out);
    }

}
 
Example 3
Source File: JvmInfo.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeLong(pid);
    out.writeString(version);
    out.writeString(vmName);
    out.writeString(vmVersion);
    out.writeString(vmVendor);
    out.writeLong(startTime);
    out.writeInt(inputArguments.length);
    for (String inputArgument : inputArguments) {
        out.writeString(inputArgument);
    }
    out.writeString(bootClassPath);
    out.writeString(classPath);
    out.writeInt(systemProperties.size());
    for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
        out.writeString(entry.getKey());
        out.writeString(entry.getValue());
    }
    mem.writeTo(out);
    out.writeStringArray(gcCollectors);
    out.writeStringArray(memoryPools);
    if (out.getVersion().onOrAfter(Version.V_2_2_0)) {
        out.writeOptionalString(useCompressedOops);
    }
}
 
Example 4
Source File: NodeFetchRequest.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeLong(jobId.getMostSignificantBits());
    out.writeLong(jobId.getLeastSignificantBits());
    out.writeVInt(fetchPhaseId);
    out.writeBoolean(closeContext);
    if (toFetch == null) {
        out.writeVInt(0);
    } else {
        out.writeVInt(toFetch.size());
        for (IntObjectCursor<? extends IntContainer> toFetchCursor : toFetch) {
            out.writeVInt(toFetchCursor.key);
            out.writeVInt(toFetchCursor.value.size());
            for (IntCursor docCursor : toFetchCursor.value) {
                out.writeInt(docCursor.value);
            }
        }
    }
}
 
Example 5
Source File: PutIndexTemplateRequest.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeString(cause);
    out.writeString(name);
    out.writeStringCollection(indexPatterns);
    out.writeInt(order);
    out.writeBoolean(create);
    writeSettingsToStream(settings, out);
    out.writeVInt(mappings.size());
    for (Map.Entry<String, String> entry : mappings.entrySet()) {
        out.writeString(entry.getKey());
        out.writeString(entry.getValue());
    }
    out.writeVInt(aliases.size());
    for (Alias alias : aliases) {
        alias.writeTo(out);
    }
    out.writeOptionalVInt(version);
}
 
Example 6
Source File: SyncedFlushResponse.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);
    shardCounts.writeTo(out);
    out.writeInt(shardsResultPerIndex.size());
    for (Map.Entry<String, List<ShardsSyncedFlushResult>> entry : shardsResultPerIndex.entrySet()) {
        out.writeString(entry.getKey());
        out.writeInt(entry.getValue().size());
        for (ShardsSyncedFlushResult shardsSyncedFlushResult : entry.getValue()) {
            shardsSyncedFlushResult.writeTo(out);
        }
    }
}
 
Example 7
Source File: GetOrChangePrimaryShardLeaseRequest.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(nodeId);
    out.writeBoolean(isGetRequest);
    out.writeInt(shardIdentifiers.size());
    for(int i = 0; i < shardIdentifiers.size(); ++i) {
        shardIdentifiers.get(i).writeTo(out);
    }
}
 
Example 8
Source File: GetOrChangePrimaryShardLeaseResponse.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.writeInt(shardsLeaseStatus.size());
    for (SimpleShardIdentifier shardIdentifier : shardsLeaseStatus.keySet()) {
        shardIdentifier.writeTo(out);
        out.writeBoolean(shardsLeaseStatus.get(shardIdentifier));
    }
}
 
Example 9
Source File: MigrateIndexTenantRequest.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.writeNullableString(tenantName);
    int indexNum = indices == null ? 0 : indices.length;
    out.writeInt(indexNum);
    for (int i = 0; i < indexNum; ++i) {
        out.writeString(indices[i]);
    }
}
 
Example 10
Source File: UncheckedObjectType.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeValueTo(StreamOutput out, Map<Object, Object> v) throws IOException {
    if (v == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        out.writeInt(v.size());
        for (Map.Entry<Object, Object> entry : v.entrySet()) {
            out.writeGenericValue(entry.getKey());
            out.writeGenericValue(entry.getValue());
        }
    }
}
 
Example 11
Source File: GeoShapeBuilder.java    From elasticsearch-plugin-geoshape with MIT License 5 votes vote down vote up
/**
 * Write to a stream
 */
@Override
protected void innerWriteTo(StreamOutput out) throws IOException {
    bucketCountThresholds.writeTo(out);
    out.writeBoolean(must_simplify);
    out.writeString(output_format.name());
    out.writeInt(simplify_zoom);
    out.writeString(simplify_algorithm.name());
}
 
Example 12
Source File: IndexMetaData.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(index);
    out.writeInt(routingNumShards);
    out.writeLong(version);
    out.writeVLong(mappingVersion);
    out.writeVLong(settingsVersion);
    out.writeByte(state.id);
    Settings.writeSettingsToStream(settings, out);
    out.writeVLongArray(primaryTerms);
    mappings.writeTo(out);
    aliases.writeTo(out);
    customData.writeTo(out);
    inSyncAllocationIds.writeTo(out);
}
 
Example 13
Source File: TransportAddress.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    byte[] bytes = address.getAddress().getAddress();  // 4 bytes (IPv4) or 16 bytes (IPv6)
    out.writeByte((byte) bytes.length); // 1 byte
    out.write(bytes, 0, bytes.length);
    out.writeString(address.getHostString());
    // don't serialize scope ids over the network!!!!
    // these only make sense with respect to the local machine, and will only formulate
    // the address incorrectly remotely.
    out.writeInt(address.getPort());
}
 
Example 14
Source File: ShardRequest.java    From crate with Apache License 2.0 5 votes vote down vote up
public void writeTo(StreamOutput out) throws IOException {
    out.writeString(id);
    out.writeLong(version);
    out.writeInt(location);
    out.writeLong(seqNo);
    out.writeLong(primaryTerm);
}
 
Example 15
Source File: InternalDateHierarchy.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.writeInt(buckets.size());
    for (InternalBucket bucket: buckets) {
        bucket.writeTo(out);
    }
}
 
Example 16
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 17
Source File: RecoverFilesRecoveryException.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.writeInt(numberOfFiles);
    totalFilesSize.writeTo(out);
}
 
Example 18
Source File: DeleteNodeRequest.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.writeString(nodeIp);
    out.writeInt(nodePort);
}
 
Example 19
Source File: AddNodeRequest.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.writeString(nodeIp);
    out.writeInt(nodePort);
}
 
Example 20
Source File: IntegerLiteralTypeSignature.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.writeInt(value);
}