Java Code Examples for org.agrona.DirectBuffer#addressOffset()
The following examples show how to use
org.agrona.DirectBuffer#addressOffset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirectBufferProxy.java From lmdbjava with Apache License 2.0 | 5 votes |
@Override protected void in(final DirectBuffer buffer, final Pointer ptr, final long ptrAddr) { final long addr = buffer.addressOffset(); final long size = buffer.capacity(); UNSAFE.putLong(ptrAddr + STRUCT_FIELD_OFFSET_DATA, addr); UNSAFE.putLong(ptrAddr + STRUCT_FIELD_OFFSET_SIZE, size); }
Example 2
Source File: DirectBufferProxy.java From lmdbjava with Apache License 2.0 | 5 votes |
@Override protected void in(final DirectBuffer buffer, final int size, final Pointer ptr, final long ptrAddr) { final long addr = buffer.addressOffset(); UNSAFE.putLong(ptrAddr + STRUCT_FIELD_OFFSET_DATA, addr); UNSAFE.putLong(ptrAddr + STRUCT_FIELD_OFFSET_SIZE, size); }
Example 3
Source File: BufferAlignmentInterceptor.java From agrona with Apache License 2.0 | 5 votes |
public static void verifyAlignment(final int index, final @Advice.This DirectBuffer buffer, final int alignment) { final int alignmentOffset = (int)(buffer.addressOffset() + index) % alignment; if (0 != alignmentOffset) { throw new BufferAlignmentException( "Unaligned " + alignment + "-byte access (index=" + index + ", offset=" + alignmentOffset + ")"); } }