use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method read.
@Test
public void read() throws IOException {
inputPlus = new AsyncStreamingInputPlus(channel);
// put two buffers of 8 bytes each into the queue.
// then read an int, then a long. the latter tests offset into the inputPlus, as well as spanning across queued buffers.
// the values of those int/long will both be '42', but spread across both queue buffers.
ByteBuf buf = channel.alloc().buffer(8);
buf.writeInt(42);
buf.writerIndex(8);
inputPlus.append(buf);
buf = channel.alloc().buffer(8);
buf.writeInt(42);
buf.writerIndex(8);
inputPlus.append(buf);
Assert.assertEquals(16, inputPlus.unsafeAvailable());
// ByteBuffer out = ByteBuffer.allocate(4);
// int readCount = inputPlus.read(out);
// Assert.assertEquals(4, readCount);
// out.flip();
// Assert.assertEquals(42, out.getInt());
// Assert.assertEquals(12, inputPlus.unsafeAvailable());
// out = ByteBuffer.allocate(8);
// readCount = inputPlus.read(out);
// Assert.assertEquals(8, readCount);
// out.flip();
// Assert.assertEquals(42, out.getLong());
// Assert.assertEquals(4, inputPlus.unsafeAvailable());
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method append_normal.
@Test
public void append_normal() {
inputPlus = new AsyncStreamingInputPlus(channel);
int size = 4;
buf = channel.alloc().buffer(size);
buf.writerIndex(size);
inputPlus.append(buf);
Assert.assertEquals(buf.readableBytes(), inputPlus.unsafeAvailable());
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method available_ClosedButWithBytes.
@Test
public void available_ClosedButWithBytes() {
inputPlus = new AsyncStreamingInputPlus(channel);
int size = 4;
buf = channel.alloc().heapBuffer(size);
buf.writerIndex(size);
inputPlus.append(buf);
inputPlus.requestClosure();
Assert.assertEquals(size, inputPlus.unsafeAvailable());
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class ZeroCopyStreamingBenchmark method partialStreamReader.
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void partialStreamReader(BenchmarkState state) throws Throwable {
EmbeddedChannel channel = createMockNettyChannel();
AsyncStreamingInputPlus in = new AsyncStreamingInputPlus(channel);
in.append(state.serializedPartialStream.retainedDuplicate());
SSTableMultiWriter sstableWriter = state.partialStreamReader.read(in);
Collection<SSTableReader> newSstables = sstableWriter.finished();
in.close();
channel.finishAndReleaseAll();
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class ZeroCopyStreamingBenchmark method blockStreamReader.
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void blockStreamReader(BenchmarkState state) throws Throwable {
EmbeddedChannel channel = createMockNettyChannel();
AsyncStreamingInputPlus in = new AsyncStreamingInputPlus(channel);
in.append(state.serializedBlockStream.retainedDuplicate());
SSTableMultiWriter sstableWriter = state.blockStreamReader.read(in);
Collection<SSTableReader> newSstables = sstableWriter.finished();
in.close();
channel.finishAndReleaseAll();
}
Aggregations