@Override public long nextId() { assert !closed; long id; while ( currentBatch == null || (id = currentBatch.nextId()) == VALUE_REPRESENTING_NULL ) { currentBatch = source.nextIdBatch( batchSize ).iterator(); } return id; }
public long nextId( StoreType type ) { return idGenerator( type ).nextId(); }
@Override public DynamicRecord nextRecord() { return allocateRecord( idGenerator.nextId() ); }
@Override public long nextId() { assert !closed; long id; while ( currentBatch == null || (id = currentBatch.nextId()) == VALUE_REPRESENTING_NULL ) { currentBatch = source.nextIdBatch( batchSize ).iterator(); } return id; }
/** * Even if instances are meant to be accessed by a single thread at a time, lifecycle calls * can guard for it nonetheless. Only the first call to close will perform close. */ @Override public synchronized void close() { if ( !closed && currentBatch != null ) { long id; while ( (id = currentBatch.nextId()) != VALUE_REPRESENTING_NULL ) { excessIdConsumer.accept( id ); } currentBatch = null; } closed = true; }
@Override public void prepare( RECORD record, int recordSize, IdSequence idSequence ) { actual.prepare( record, recordSize, idSequence ); if ( !record.hasSecondaryUnitId() ) { record.setSecondaryUnitId( idSequence.nextId() ); } }
PropertyRecord currentRecord = propertyRecords.create( propertyRecordIdGenerator.nextId(), owner ) .forChangingData(); createdPropertyRecords.accept( currentRecord ); long propertyId = propertyRecordIdGenerator.nextId(); currentRecord = propertyRecords.create( propertyId, owner ).forChangingData(); createdPropertyRecords.accept( currentRecord );
@Test public void shouldReturnIdImmediatelyAfterRecordId() { // given PrepareIdSequence idSequence = new SecondaryUnitPrepareIdSequence(); IdSequence actual = mock( IdSequence.class ); // when long recordId = 10; IdSequence prepared = idSequence.apply( actual ).apply( recordId ); long nextRecordId = prepared.nextId(); // then assertEquals( 10 + 1, nextRecordId ); verifyNoMoreInteractions( actual ); }
long id = idGenerator.nextId(); change = relGroupRecords.create( id, type ); RelationshipGroupRecord record = change.forChangingData();
freeHost = propertyRecords.create( propertyRecordIdGenerator.nextId(), primitive ).forChangingData(); freeHost.setInUse( true ); if ( primitive.getNextProp() != Record.NO_NEXT_PROPERTY.intValue() )
@Override public DynamicRecord nextRecord() { return allocateRecord( idGenerator.nextId() ); }
public long nextId( StoreType type ) { return idGenerator( type ).nextId(); }
/** * Even if instances are meant to be accessed by a single thread at a time, lifecycle calls * can guard for it nonetheless. Only the first call to close will perform close. */ @Override public synchronized void close() { if ( !closed && currentBatch != null ) { long id; while ( (id = currentBatch.nextId()) != VALUE_REPRESENTING_NULL ) { excessIdConsumer.accept( id ); } currentBatch = null; } closed = true; }
@Override public final void prepare( RECORD record, int recordSize, IdSequence idSequence ) { if ( record.inUse() ) { int requiredLength = HEADER_BYTE + requiredDataLength( record ); boolean requiresSecondaryUnit = requiredLength > recordSize; record.setRequiresSecondaryUnit( requiresSecondaryUnit ); if ( record.requiresSecondaryUnit() && !record.hasSecondaryUnitId() ) { // Allocate a new id at this point, but this is not the time to free this ID the the case where // this record doesn't need this secondary unit anymore... that needs to be done when applying to store. record.setSecondaryUnitId( idSequence.nextId() ); } } }
@Override public final void prepare( RECORD record, int recordSize, IdSequence idSequence ) { if ( record.inUse() ) { record.setUseFixedReferences( canUseFixedReferences( record, recordSize )); if ( !record.isUseFixedReferences() ) { int requiredLength = HEADER_BYTE + requiredDataLength( record ); boolean requiresSecondaryUnit = requiredLength > recordSize; record.setRequiresSecondaryUnit( requiresSecondaryUnit ); if ( record.requiresSecondaryUnit() && !record.hasSecondaryUnitId() ) { // Allocate a new id at this point, but this is not the time to free this ID the the case where // this record doesn't need this secondary unit anymore... that needs to be done when applying to store. record.setSecondaryUnitId( idSequence.nextId() ); } } } }
@Override public final void prepare( RECORD record, int recordSize, IdSequence idSequence ) { if ( record.inUse() ) { record.setUseFixedReferences( canUseFixedReferences( record, recordSize )); if ( !record.isUseFixedReferences() ) { int requiredLength = HEADER_BYTE + requiredDataLength( record ); boolean requiresSecondaryUnit = requiredLength > recordSize; record.setRequiresSecondaryUnit( requiresSecondaryUnit ); if ( record.requiresSecondaryUnit() && !record.hasSecondaryUnitId() ) { // Allocate a new id at this point, but this is not the time to free this ID the the case where // this record doesn't need this secondary unit anymore... that needs to be done when applying to store. record.setSecondaryUnitId( idSequence.nextId() ); } } } }
@Override public final void prepare( RECORD record, int recordSize, IdSequence idSequence ) { if ( record.inUse() ) { record.setUseFixedReferences( canUseFixedReferences( record, recordSize )); if ( !record.isUseFixedReferences() ) { int requiredLength = HEADER_BYTE + requiredDataLength( record ); boolean requiresSecondaryUnit = requiredLength > recordSize; record.setRequiresSecondaryUnit( requiresSecondaryUnit ); if ( record.requiresSecondaryUnit() && !record.hasSecondaryUnitId() ) { // Allocate a new id at this point, but this is not the time to free this ID the the case where // this record doesn't need this secondary unit anymore... that needs to be done when applying to store. record.setSecondaryUnitId( idSequence.nextId() ); } } } }
@Override public final void prepare( RECORD record, int recordSize, IdSequence idSequence ) { if ( record.inUse() ) { record.setUseFixedReferences( canUseFixedReferences( record, recordSize )); if ( !record.isUseFixedReferences() ) { int requiredLength = HEADER_BYTE + requiredDataLength( record ); boolean requiresSecondaryUnit = requiredLength > recordSize; record.setRequiresSecondaryUnit( requiresSecondaryUnit ); if ( record.requiresSecondaryUnit() && !record.hasSecondaryUnitId() ) { // Allocate a new id at this point, but this is not the time to free this ID the the case where // this record doesn't need this secondary unit anymore... that needs to be done when applying to store. record.setSecondaryUnitId( idSequence.nextId() ); } } } }
long id = idGenerator.nextId(); change = relGroupRecords.create( id, type ); RelationshipGroupRecord record = change.forChangingData();