/** 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); }
public TransBlob(ComponentId cid, BufferChannel file) { super(cid) ; this.file = file ; read() ; }
@Override public void finishRecovery() { if ( recoveryChange ) write() ; }
@Test public void transBlob_1() { String str = "Hello World" ; write(transactional, transBlob, str) ; String str2 = read(transactional, transBlob) ; assertEquals(str, str2) ; String str3 = transBlob.getString() ; assertEquals(str, str3) ; }
public ByteBuffer getBlob() { if ( isActiveTxn() ) return getDataState().getByteBuffer() ; return blobRef.get() ; }
@Override protected void _commit(TxnId txnId, BlobState state) { if ( ! state.hasChanged ) return; // NB Change reference. blobRef.set(state.getByteBuffer()) ; write() ; }
@Override protected ByteBuffer _commitPrepare(TxnId txnId, BlobState state) { if ( ! state.hasChanged ) return null; return state.getByteBuffer() ; }
@Override protected TxnBinFile _begin(ReadWrite readWrite, TxnId txnId) { // Atomic read across the two because it's called from within // TransactionCoordinator.begin$ where there is a lock. return createState() ; }
@Override public void sync() { // No-op in transactional mode. checkWriteTxn(); }
@Override protected BlobState _promote(TxnId txnId, BlobState state) { // Our write state is the read state. return createState(); }
BlobState(ByteBuffer bb) { setByteBuffer(bb) ; } void setByteBuffer(ByteBuffer bb) {
@Test public void transBlob_1() { String str = "Hello World" ; write(transactional, transBlob, str) ; String str2 = read(transactional, transBlob) ; assertEquals(str, str2) ; String str3 = transBlob.getString() ; assertEquals(str, str3) ; }
/** 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); }
public ByteBuffer getBlob() { if ( isActiveTxn() ) return getDataState().getByteBuffer() ; return blobRef.get() ; }
@Override protected void _commit(TxnId txnId, BlobState state) { if ( ! state.hasChanged ) return; // NB Change reference. blobRef.set(state.getByteBuffer()) ; write() ; }
public TransBlob(ComponentId cid, BufferChannel file) { super(cid) ; this.file = file ; read() ; }
@Override public void finishRecovery() { if ( recoveryChange ) write() ; }
@Override protected ByteBuffer _commitPrepare(TxnId txnId, BlobState state) { if ( ! state.hasChanged ) return null; return state.getByteBuffer() ; }
@Override protected TxnBinFile _promote(TxnId txnId, TxnBinFile state) { return createState() ; }
@Override public void sync() { // No-op in transactional mode. checkWriteTxn(); }