@Test public void shouldContinueThroughEmptyIdBatch() { // given IdSequence idSource = mock( IdSequence.class ); Iterator<IdRange> ranges = asList( new IdRange( EMPTY_LONG_ARRAY, 0, BATCH_SIZE ), new IdRange( EMPTY_LONG_ARRAY, BATCH_SIZE, 0 ), new IdRange( EMPTY_LONG_ARRAY, BATCH_SIZE, BATCH_SIZE ) ).iterator(); when( idSource.nextIdBatch( anyInt() ) ).thenAnswer( invocation -> ranges.next() ); RenewableBatchIdSequence ids = new RenewableBatchIdSequence( idSource, BATCH_SIZE, excessIds::add ); // when/then for ( long expectedId = 0; expectedId < BATCH_SIZE * 2; expectedId++ ) { assertEquals( expectedId, ids.nextId() ); } }
public RenewableBatchIdSequences( NeoStores stores, int batchSize ) { for ( StoreType type : StoreType.values() ) { if ( type.isRecordStore() ) { RecordStore<AbstractBaseRecord> store = stores.getRecordStore( type ); if ( type.isLimitedIdStore() || batchSize == 1 ) { // This is a token store or otherwise meta-data store, so let's not add batching for it types[type.ordinal()] = store; } else { // This is a normal record store where id batching is beneficial types[type.ordinal()] = new RenewableBatchIdSequence( store, batchSize, store::freeId ); } } } }
public RenewableBatchIdSequences( NeoStores stores, int batchSize ) { for ( StoreType type : StoreType.values() ) { if ( type.isRecordStore() ) { RecordStore<AbstractBaseRecord> store = stores.getRecordStore( type ); if ( type.isLimitedIdStore() || batchSize == 1 ) { // This is a token store or otherwise meta-data store, so let's not add batching for it types[type.ordinal()] = store; } else { // This is a normal record store where id batching is beneficial types[type.ordinal()] = new RenewableBatchIdSequence( store, batchSize, store::freeId ); } } } }