use of io.pravega.common.util.ByteArraySegment in project pravega by pravega.
the class DurableDataLogTestBase method populate.
protected TreeMap<LogAddress, byte[]> populate(DurableDataLog log, int writeCount) {
TreeMap<LogAddress, byte[]> writtenData = new TreeMap<>(Comparator.comparingLong(LogAddress::getSequence));
val data = new ArrayList<byte[]>();
val futures = new ArrayList<CompletableFuture<LogAddress>>();
for (int i = 0; i < writeCount; i++) {
byte[] writeData = getWriteData();
futures.add(log.append(new ByteArraySegment(writeData), TIMEOUT));
data.add(writeData);
}
val addresses = Futures.allOfWithResults(futures).join();
for (int i = 0; i < data.size(); i++) {
writtenData.put(addresses.get(i), data.get(i));
}
return writtenData;
}
use of io.pravega.common.util.ByteArraySegment in project pravega by pravega.
the class VersionedSerializerTests method testSingleTypeNonSeekableOutput.
/**
* Tests Single Type serializer using a Non-Seekable OutputStream.
*/
@Test
public void testSingleTypeNonSeekableOutput() throws IOException {
testSingleType((tc, s) -> {
val os = new ByteArrayOutputStream();
s.serialize(os, tc);
return new ByteArraySegment(os.toByteArray());
});
}
use of io.pravega.common.util.ByteArraySegment in project pravega by pravega.
the class RevisionDataOutputStreamTests method testNonSeekableOutputImpl.
/**
* Tests the NonSeekableRevisionDataOutput class.
*/
@Test
public void testNonSeekableOutputImpl() throws Exception {
@Cleanup val s = new ByteArrayOutputStream();
@Cleanup val impl = RevisionDataOutputStream.wrap(s);
testImpl(impl, () -> new ByteArraySegment(s.toByteArray()));
}
Aggregations