public static StreamInput wrap(byte[] bytes) { return wrap(bytes, 0, bytes.length); }
/** * @param data input bytes * @param localNode used to set the local node in the cluster state. */ public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode, NamedWriteableRegistry registry) throws IOException { StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(data), registry); return readFrom(in, localNode); } }
final byte[] buffer = new byte[size]; input.readBytes(buffer, 0, buffer.length); StreamInput in = StreamInput.wrap(buffer); Exception t = in.readException(); if (t instanceof CorruptIndexException) {
@Override public StreamInput streamInput() { return StreamInput.wrap(bytes, offset, length); }
public static StreamInput wrap(byte[] bytes) { return wrap(bytes, 0, bytes.length); }
public static StreamInput wrap(byte[] bytes) { return wrap(bytes, 0, bytes.length); }
public static StreamInput wrap(byte[] bytes) { return wrap(bytes, 0, bytes.length); }
public static StreamInput wrap(byte[] bytes) { return wrap(bytes, 0, bytes.length); }
/** * @param data input bytes * @param localNode used to set the local node in the cluster state. */ public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode) throws IOException { return readFrom(StreamInput.wrap(data), localNode); }
@Override public Map<String, String> load(byte[] source) throws IOException { Properties props = new NoDuplicatesProperties(); StreamInput stream = StreamInput.wrap(source); try { props.load(stream); Map<String, String> result = newHashMap(); for (Map.Entry entry : props.entrySet()) { result.put((String) entry.getKey(), (String) entry.getValue()); } return result; } finally { IOUtils.closeWhileHandlingException(stream); } }
/** * @param data input bytes * @param localNode used to set the local node in the cluster state. */ public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode, NamedWriteableRegistry registry) throws IOException { StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(data), registry); return readFrom(in, localNode); } }
/** * @param data input bytes * @param localNode used to set the local node in the cluster state. */ public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode, NamedWriteableRegistry registry) throws IOException { StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(data), registry); return readFrom(in, localNode); } }
/** * @param data input bytes * @param localNode used to set the local node in the cluster state. */ public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode, NamedWriteableRegistry registry) throws IOException { StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(data), registry); return readFrom(in, localNode); } }
public TermVector(BytesReference termVectors, long readOffset) throws IOException { this.perFieldTermVectorInput = StreamInput.wrap(termVectors.toBytesArray()); this.readOffset = readOffset; reset(); }
final byte[] buffer = new byte[size]; input.readBytes(buffer, 0, buffer.length); StreamInput in = StreamInput.wrap(buffer); Exception t = in.readException(); if (t instanceof CorruptIndexException) {
final byte[] buffer = new byte[size]; input.readBytes(buffer, 0, buffer.length); StreamInput in = StreamInput.wrap(buffer); Exception t = in.readException(); if (t instanceof CorruptIndexException) {
public static StreamInput wrap(BytesReference reference) { if (reference.hasArray() == false) { reference = reference.toBytesArray(); } return wrap(reference.array(), reference.arrayOffset(), reference.length()); }
/** * @param headerRef Stores offsets per field in the {@code termVectors} and some * header information as {@link BytesRef}. * @param termVectors Stores the actual term vectors as a {@link BytesRef}. */ public TermVectorsFields(BytesReference headerRef, BytesReference termVectors) throws IOException { StreamInput header = StreamInput.wrap(headerRef.toBytesArray()); fieldMap = new ObjectLongHashMap<>(); // here we read the header to fill the field offset map String headerString = header.readString(); assert headerString.equals("TV"); int version = header.readInt(); assert version == -1; hasTermStatistic = header.readBoolean(); hasFieldStatistic = header.readBoolean(); hasScores = header.readBoolean(); final int numFields = header.readVInt(); for (int i = 0; i < numFields; i++) { fieldMap.put((header.readString()), header.readVLong()); } header.close(); // reference to the term vector data this.termVectors = termVectors; }
try { transportServiceAdapter.addBytesReceived(data.length); StreamInput stream = StreamInput.wrap(data); stream.setVersion(version);
public void testStreamInputMarkAndReset() throws IOException { int length = randomIntBetween(10, scaledRandomIntBetween(PAGE_SIZE * 2, PAGE_SIZE * 20)); BytesReference pbr = newBytesReference(length); StreamInput si = pbr.streamInput(); assertNotNull(si); StreamInput wrap = StreamInput.wrap(BytesReference.toBytes(pbr)); while(wrap.available() > 0) { if (rarely()) { wrap.mark(Integer.MAX_VALUE); si.mark(Integer.MAX_VALUE); } else if (rarely()) { wrap.reset(); si.reset(); } assertEquals(si.readByte(), wrap.readByte()); assertEquals(si.available(), wrap.available()); } }