use of org.agrona.concurrent.UnsafeBuffer in project deeplearning4j by deeplearning4j.
the class SbeStatsInitializationReport method encode.
@Override
public byte[] encode() {
byte[] bytes = new byte[encodingLengthBytes()];
MutableDirectBuffer buffer = new UnsafeBuffer(bytes);
encode(buffer);
return bytes;
}
use of org.agrona.concurrent.UnsafeBuffer in project deeplearning4j by deeplearning4j.
the class SbeStatsReport method encode.
@Override
public byte[] encode() {
byte[] bytes = new byte[encodingLengthBytes()];
MutableDirectBuffer buffer = new UnsafeBuffer(bytes);
encode(buffer);
return bytes;
}
use of org.agrona.concurrent.UnsafeBuffer in project deeplearning4j by deeplearning4j.
the class SbeStatsReport method decode.
@Override
public void decode(byte[] decode) {
MutableDirectBuffer buffer = new UnsafeBuffer(decode);
decode(buffer);
}
use of org.agrona.concurrent.UnsafeBuffer in project Aeron by real-logic.
the class ArchiveFileUtil method archiveMetaFileFormatDecoder.
static ArchiveDescriptorDecoder archiveMetaFileFormatDecoder(final File metaFile) throws IOException {
try (RandomAccessFile randomAccessFile = new RandomAccessFile(metaFile, "rw");
FileChannel metadataFileChannel = randomAccessFile.getChannel()) {
final MappedByteBuffer metaDataBuffer = metadataFileChannel.map(FileChannel.MapMode.READ_WRITE, 0, ArchiveIndex.INDEX_RECORD_SIZE);
final ArchiveDescriptorDecoder decoder = new ArchiveDescriptorDecoder();
return decoder.wrap(new UnsafeBuffer(metaDataBuffer), ArchiveIndex.INDEX_FRAME_LENGTH, ArchiveDescriptorDecoder.BLOCK_LENGTH, ArchiveDescriptorDecoder.SCHEMA_VERSION);
}
}
use of org.agrona.concurrent.UnsafeBuffer in project Aeron by real-logic.
the class BufferBuilderTest method shouldAppendOneBufferWithoutResizing.
@Test
public void shouldAppendOneBufferWithoutResizing() {
final UnsafeBuffer srcBuffer = new UnsafeBuffer(new byte[INITIAL_CAPACITY]);
final byte[] bytes = "Hello World".getBytes(StandardCharsets.UTF_8);
srcBuffer.putBytes(0, bytes, 0, bytes.length);
bufferBuilder.append(srcBuffer, 0, bytes.length);
final byte[] temp = new byte[bytes.length];
bufferBuilder.buffer().getBytes(0, temp, 0, bytes.length);
assertThat(bufferBuilder.limit(), is(bytes.length));
assertThat(bufferBuilder.capacity(), is(INITIAL_CAPACITY));
assertArrayEquals(temp, bytes);
}
Aggregations