Search in sources :

Example 1 with IdRangeIterator

use of org.neo4j.internal.id.IdRangeIterator in project neo4j by neo4j.

the class BatchingIdGetter method nextId.

@Override
public long nextId(CursorContext cursorContext) {
    long id;
    if (batch == null || (id = batch.nextId(cursorContext)) == VALUE_REPRESENTING_NULL) {
        idExpectation = NO_ID_EXPECTATION;
        IdRange idRange = source.nextIdBatch(batchSize, true, cursorContext);
        while (IdValidator.hasReservedIdInRange(idRange.getRangeStart(), idRange.getRangeStart() + idRange.getRangeLength())) {
            idRange = source.nextIdBatch(batchSize, true, cursorContext);
        }
        batch = new IdRangeIterator(idRange);
        id = batch.nextId(cursorContext);
    }
    if (idExpectation != NO_ID_EXPECTATION) {
        if (id != idExpectation) {
            throw new IllegalStateException(format("Id generator allocated range with non-consecutive IDs, expected:%d, but got:%d", idExpectation, id));
        }
    }
    idExpectation = id + 1;
    return id;
}
Also used : IdRangeIterator(org.neo4j.internal.id.IdRangeIterator) IdRange(org.neo4j.internal.id.IdRange)

Aggregations

IdRange (org.neo4j.internal.id.IdRange)1 IdRangeIterator (org.neo4j.internal.id.IdRangeIterator)1