Java Code Examples for org.agrona.concurrent.UnsafeBuffer#byteArray()
The following examples show how to use
org.agrona.concurrent.UnsafeBuffer#byteArray() .
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: RocksDbStorage.java From nd4j with Apache License 2.0 | 6 votes |
/** * Add an ndarray to the storage * * @param array the array to add */ @Override public void addUpdate(NDArrayMessage array) { UnsafeBuffer directBuffer = (UnsafeBuffer) NDArrayMessage.toBuffer(array); byte[] data = directBuffer.byteArray(); if (data == null) { data = new byte[directBuffer.capacity()]; directBuffer.getBytes(0, data, 0, data.length); } byte[] key = ByteBuffer.allocate(4).putInt(size).array(); try { db.put(key, data); } catch (RocksDBException e) { throw new RuntimeException(e); } size++; }
Example 2
Source File: RocksDbStorage.java From deeplearning4j with Apache License 2.0 | 6 votes |
/** * Add an ndarray to the storage * * @param array the array to add */ @Override public void addUpdate(NDArrayMessage array) { UnsafeBuffer directBuffer = (UnsafeBuffer) NDArrayMessage.toBuffer(array); byte[] data = directBuffer.byteArray(); if (data == null) { data = new byte[directBuffer.capacity()]; directBuffer.getBytes(0, data, 0, data.length); } byte[] key = ByteBuffer.allocate(4).putInt(size).array(); try { db.put(key, data); } catch (RocksDBException e) { throw new RuntimeException(e); } size++; }
Example 3
Source File: UnsafeBufferPosition.java From agrona with Apache License 2.0 | 5 votes |
/** * Map a position over a buffer and this indicator owns the counter for reclamation. * * @param buffer containing the counter. * @param counterId identifier of the counter. * @param countersManager to be used for freeing the counter when this is closed. */ public UnsafeBufferPosition(final UnsafeBuffer buffer, final int counterId, final CountersManager countersManager) { this.counterId = counterId; this.countersManager = countersManager; this.byteArray = buffer.byteArray(); this.byteBuffer = buffer.byteBuffer(); final int counterOffset = CountersManager.counterOffset(counterId); buffer.boundsCheck(counterOffset, SIZE_OF_LONG); this.addressOffset = buffer.addressOffset() + counterOffset; }