private static void expected(@NotNull ExcerptTailer tailer, String expected) { try (DocumentContext dc = tailer.readingDocument()) { assertTrue("No document found", dc.isPresent()); Bytes bytes2 = Bytes.elasticHeapByteBuffer(128); dc.wire().copyTo(new TextWire(bytes2)); assertEquals(expected, bytes2.toString()); } }
Bytes b = Bytes.elasticHeapByteBuffer(128); final ExcerptTailer tailer = queue.createTailer(); tailer.readBytes(b);
static Bytes<?> allocateDefaultElasticBytes(long bytesCapacity) { if (bytesCapacity <= Bytes.MAX_BYTE_BUFFER_CAPACITY) { return Bytes.elasticHeapByteBuffer((int) bytesCapacity); } else { return Bytes.allocateElasticDirect(bytesCapacity); } } }
@Override protected void setValue(Object o, @NotNull BytesIn read) throws IllegalAccessException, IORuntimeException { @NotNull Bytes bytes = (Bytes) field.get(o); long stopBit = read.readStopBit(); if (stopBit == -1) { if (bytes != null) bytes.release(); field.set(o, null); return; } int length = Maths.toUInt31(stopBit); @NotNull Bytes bs; if (bytes == null) { bs = Bytes.elasticHeapByteBuffer(length); } else { bs = bytes; } Object uo = bs.underlyingObject(); if (uo instanceof ByteBuffer && !(bs.bytesStore() instanceof NativeBytesStore)) { read.read(((ByteBuffer) uo).array(), 0, length); } else { bs.clear(); read.read(bs, length); } bs.readLimit(length); field.set(o, bs); } }