question: public void test_allocationContexts ( ) throws IOException { final Journal store = ( Journal ) getStore ( ) ; try { final RWStrategy bs = ( RWStrategy ) store . getBufferStrategy ( ) ; final RWStore rw = bs . getStore ( ) ; final IAllocationContext allocContext1 = rw . newAllocationContext ( true ) ; final IAllocationContext allocContext2 = rw . newAllocationContext ( true ) ; final int sze = 650 ; final byte [ ] buf = new byte [ sze + 4 ] ; r . nextBytes ( buf ) ; final long addr1a = bs . write ( ByteBuffer . wrap ( buf ) , allocContext1 ) ; final long addr1b = bs . write ( ByteBuffer . wrap ( buf ) , allocContext1 ) ; rw . detachContext ( allocContext1 ) ; final long addr2a = bs . write ( ByteBuffer . wrap ( buf ) , allocContext2 ) ; final long addr2b = bs . write ( ByteBuffer . wrap ( buf ) , allocContext2 ) ; rw . detachContext ( allocContext2 ) ; try { bs . write ( ByteBuffer . wrap ( buf ) , allocContext1 ) ; fail ( "Should have failed to re-use detached context" ) ; } catch ( IllegalStateException ise ) { } final IAllocationContext allocContext3 = rw . newAllocationContext ( true ) ; final long addr1c = bs . write ( ByteBuffer . wrap ( buf ) , allocContext3 ) ; assertTrue ( "allocator re-use" , bs . getPhysicalAddress ( addr1c ) > bs . getPhysicalAddress ( addr2b ) ) ; bs . delete ( addr1c , allocContext3 ) ; final long addr1d = bs . write ( ByteBuffer . wrap ( buf ) , allocContext3 ) ; assertTrue ( "re-allocation" , addr1c == addr1d ) ; rw . detachContext ( allocContext3 ) ; store . commit ( ) ; bs . delete ( addr1d ) ; final long addr1e = bs . write ( ByteBuffer . wrap ( buf ) ) ; assertTrue ( "deferred-delete" , addr1e != addr1d ) ; store . commit ( ) ; } finally { store . destroy ( ) ; } }
target:  From a RWStore, creates multiple AllocationContexts to isolate updates, re-allocate storage and protect against by concurrent Contexts. This is the core functionality required to support Transactions. If an allocation is made for an AllocationContext then this will result in a ContextAllocation object being created in the RWStore within which "shadow" allocations can be made. If such a shadow allocation is deleted, within the AllocationContext, then this can be removed immediately.