/** * Reads a bytes reference from this stream, might hold an actual reference to the underlying * bytes of the stream. */ public BytesReference readBytesReference() throws IOException { int length = readArraySize(); return readBytesReference(length); }
/** * Read from a stream. */ protected DecayFunctionBuilder(StreamInput in) throws IOException { super(in); fieldName = in.readString(); functionBytes = in.readBytesReference(); multiValueMode = MultiValueMode.readMultiValueModeFrom(in); }
public Text readText() throws IOException { // use StringAndBytes so we can cache the string if its ever converted to it int length = readInt(); return new Text(readBytesReference(length)); }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); bytes = in.readBytesReference(); version = in.getVersion(); }
/** * Reads an optional bytes reference from this stream. It might hold an actual reference to the underlying bytes of the stream. Use this * only if you must differentiate null from empty. Use {@link StreamInput#readBytesReference()} and * {@link StreamOutput#writeBytesReference(BytesReference)} if you do not. */ @Nullable public BytesReference readOptionalBytesReference() throws IOException { int length = readVInt() - 1; if (length < 0) { return null; } return readBytesReference(length); }
HandshakeRequest(StreamInput streamInput) throws IOException { super(streamInput); BytesReference remainingMessage; try { remainingMessage = streamInput.readBytesReference(); } catch (EOFException e) { remainingMessage = null; } if (remainingMessage == null) { version = null; } else { try (StreamInput messageStreamInput = remainingMessage.streamInput()) { this.version = Version.readVersion(messageStreamInput); } } }
@Nullable public Text readOptionalText() throws IOException { int length = readInt(); if (length == -1) { return null; } return new Text(readBytesReference(length)); }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); int size = in.readVInt(); Map<String, Map<String, Map<String, FieldMappingMetaData>>> indexMapBuilder = new HashMap<>(size); for (int i = 0; i < size; i++) { String index = in.readString(); int typesSize = in.readVInt(); Map<String, Map<String, FieldMappingMetaData>> typeMapBuilder = new HashMap<>(typesSize); for (int j = 0; j < typesSize; j++) { String type = in.readString(); int fieldSize = in.readVInt(); Map<String, FieldMappingMetaData> fieldMapBuilder = new HashMap<>(fieldSize); for (int k = 0; k < fieldSize; k++) { fieldMapBuilder.put(in.readString(), new FieldMappingMetaData(in.readString(), in.readBytesReference())); } typeMapBuilder.put(type, unmodifiableMap(fieldMapBuilder)); } indexMapBuilder.put(index, unmodifiableMap(typeMapBuilder)); } mappings = unmodifiableMap(indexMapBuilder); }
public static PipelineConfiguration readFrom(StreamInput in) throws IOException { if (in.getVersion().onOrAfter(Version.V_5_3_0)) { return new PipelineConfiguration(in.readString(), in.readBytesReference(), in.readEnum(XContentType.class)); } else { final String id = in.readString(); final BytesReference config = in.readBytesReference(); return new PipelineConfiguration(id, config, XContentHelper.xContentType(config)); } }
@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); id = in.readString(); source = in.readBytesReference(); if (in.getVersion().onOrAfter(Version.V_5_3_0)) { xContentType = in.readEnum(XContentType.class); } else { xContentType = XContentHelper.xContentType(source); } }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); id = in.readOptionalString(); verbose = in.readBoolean(); source = in.readBytesReference(); if (in.getVersion().onOrAfter(Version.V_5_3_0)) { xContentType = in.readEnum(XContentType.class); } else { xContentType = XContentHelper.xContentType(source); } }
/** * Reads a {@link StoredScriptSource} from a stream. Version 5.3+ will read * all of the lang, source, and options parameters. For versions prior to 5.3, * only the source parameter will be read in as a bytes reference. */ public StoredScriptSource(StreamInput in) throws IOException { if (in.getVersion().onOrAfter(Version.V_5_3_0)) { this.lang = in.readString(); this.source = in.readString(); @SuppressWarnings("unchecked") Map<String, String> options = (Map<String, String>)(Map)in.readMap(); this.options = options; } else { this.lang = null; this.source = in.readBytesReference().utf8ToString(); this.options = null; } }
exists = in.readBoolean(); if (exists) { source = in.readBytesReference(); if (source.length() == 0) { source = null;
/** * Read from a stream. */ public RemoteInfo(StreamInput in) throws IOException { scheme = in.readString(); host = in.readString(); port = in.readVInt(); query = in.readBytesReference(); username = in.readOptionalString(); password = in.readOptionalString(); int headersLength = in.readVInt(); Map<String, String> headers = new HashMap<>(headersLength); for (int i = 0; i < headersLength; i++) { headers.put(in.readString(), in.readString()); } this.headers = unmodifiableMap(headers); if (in.getVersion().onOrAfter(Version.V_5_2_0)) { socketTimeout = in.readTimeValue(); connectTimeout = in.readTimeValue(); } else { socketTimeout = DEFAULT_SOCKET_TIMEOUT; connectTimeout = DEFAULT_CONNECT_TIMEOUT; } if (in.getVersion().onOrAfter(Version.V_6_4_0)) { pathPrefix = in.readOptionalString(); } else { pathPrefix = null; } }
@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.readString(); content = in.readBytesReference(); Version writtenBy = Lucene.parseVersionLenient(in.readString(), null); assert writtenBy != null; metaData = new StoreFileMetaData(name, length, checksum, writtenBy); lastChunk = in.readBoolean(); totalTranslogOps = in.readVInt(); sourceThrottleTimeInNanos = in.readLong(); }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.getVersion().before(Version.V_6_0_0_alpha2)) { in.readString(); // read lang from previous versions } id = in.readOptionalString(); content = in.readBytesReference(); if (in.getVersion().onOrAfter(Version.V_5_3_0)) { xContentType = in.readEnum(XContentType.class); } else { xContentType = XContentHelper.xContentType(content); } if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha2)) { context = in.readOptionalString(); source = new StoredScriptSource(in); } else { source = StoredScriptSource.parse(content, xContentType == null ? XContentType.JSON : xContentType); } }
doc = in.readBytesReference(); if (in.getVersion().onOrAfter(Version.V_5_3_0)) { xContentType = in.readEnum(XContentType.class);
private Index(final StreamInput in) throws IOException { final int format = in.readVInt(); // SERIALIZATION_FORMAT assert format >= FORMAT_2_X : "format was: " + format; id = in.readString(); type = in.readString(); source = in.readBytesReference(); routing = in.readOptionalString(); parent = in.readOptionalString(); this.version = in.readLong(); if (format < FORMAT_SEQ_NO) { in.readLong(); // timestamp in.readLong(); // ttl } this.versionType = VersionType.fromValue(in.readByte()); assert versionType.validateVersionForWrites(this.version) : "invalid version for writes: " + this.version; if (format >= FORMAT_AUTO_GENERATED_IDS) { this.autoGeneratedIdTimestamp = in.readLong(); } else { this.autoGeneratedIdTimestamp = IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP; } if (format >= FORMAT_SEQ_NO) { seqNo = in.readLong(); primaryTerm = in.readLong(); } else { seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO; primaryTerm = 0; } }
source = in.readBytesReference(); opType = OpType.fromId(in.readByte()); version = in.readLong();