DefaultSegmentWriter implements SegmentWriter { @NotNull RecordId writeBlock(@NotNull final byte[] bytes, final int offset, final int length) throws IOException { return new SegmentWriteOperation(writeOperationHandler.getGCGeneration()) .writeBlock(bytes, offset, length); } DefaultSegmentWriter(
            @NotNull SegmentStore store,
            @NotNull SegmentReader reader,
            @NotNull SegmentIdProvider idProvider,
            @Nullable BlobStore blobStore,
            @NotNull WriterCacheManager cacheManager,
            @NotNull WriteOperationHandler writeOperationHandler
    ); @Override void flush(); @Override @NotNull RecordId writeBlob(@NotNull final Blob blob); @Override @NotNull RecordId writeStream(@NotNull final InputStream stream); @Override @NotNull RecordId writeNode(@NotNull final NodeState state, @Nullable final Buffer stableIdBytes);  }
@Test public void testBlockRecord() throws IOException { RecordId blockId = writer.writeBlock(bytes, 0, bytes.length); BlockRecord block = new BlockRecord(blockId, bytes.length); for (int n = 1; n < bytes.length; n++) { for (int i = 0; i + n <= bytes.length; i++) { Arrays.fill(bytes, i, i + n, (byte) '.'); assertEquals(n, block.read(i, bytes, i, n)); assertEquals(HELLO_WORLD, new String(bytes, Charsets.UTF_8)); } } byte[] large = new byte[bytes.length * 2]; assertEquals(bytes.length, block.read(0, large, 0, large.length)); assertEquals(HELLO_WORLD, new String(large, 0, bytes.length, Charsets.UTF_8)); }