public ByteBuffer getBlob() { if ( isActiveTxn() ) return getDataState().getByteBuffer() ; return blobRef.get() ; }
public ByteBuffer getBlob() { if ( isActiveTxn() ) return getDataState().getByteBuffer() ; return blobRef.get() ; }
/** Set the byte buffer. * The byte buffer should not be accessed except by {@link #getBlob}. * We avoid a copy in and copy out - we trust the caller. * The byte buffer should be configured for read if used with {@link #getString}. */ public void setBlob(ByteBuffer bb) { checkWriteTxn(); getDataState().setByteBuffer(bb); }
/** Set the byte buffer. * The byte buffer should not be accessed except by {@link #getBlob}. * We avoid a copy in and copy out - we trust the caller. * The byte buffer should be configured for read if used with {@link #getString}. */ public void setBlob(ByteBuffer bb) { checkWriteTxn(); getDataState().setByteBuffer(bb); }
/** Set data from string - convenience operation */ public void setString(String dataStr) { checkWriteTxn(); if ( dataStr == null ) { setBlob(null); return ; } // Attempt to reuse the write-transaction byte buffer // We can't reuse if it's the blobRef (shared by other transactions) // but if it's a new to this write transaction buffer we can reuse. int maxNeeded = dataStr.length()*4 ; ByteBuffer bb = getDataState().getByteBuffer() ; if ( bb == blobRef.get() ) bb = ByteBuffer.allocate(maxNeeded) ; else if ( bb.capacity() >= maxNeeded ) bb.clear() ; else bb = ByteBuffer.allocate(maxNeeded) ; Bytes.toByteBuffer(dataStr, bb) ; bb.flip() ; setBlob(bb); }
/** Set data from string - convenience operation */ public void setString(String dataStr) { checkWriteTxn(); if ( dataStr == null ) { setBlob(null); return ; } // Attempt to reuse the write-transaction byte buffer // We can't reuse if it's the blobRef (shared by other transactions) // but if it's a new to this write transaction buffer we can reuse. int maxNeeded = dataStr.length()*4 ; ByteBuffer bb = getDataState().getByteBuffer() ; if ( bb == blobRef.get() ) bb = ByteBuffer.allocate(maxNeeded) ; else if ( bb.capacity() >= maxNeeded ) bb.clear() ; else bb = ByteBuffer.allocate(maxNeeded) ; Bytes.toByteBuffer(dataStr, bb) ; bb.flip() ; setBlob(bb); }