use of org.neo4j.index.internal.gbptree.Writer in project neo4j by neo4j.
the class GBPTreeGenericCountsStore method directUpdater.
/**
* Opens and returns a {@link CountUpdater} which makes direct insertions into the backing tree. This comes from the use case of having a way
* to build the initial data set without the context of transactions, such as batch-insertion or initial import.
*
* @param applyDeltas if {@code true} the writer will apply the changes as deltas, which means reading from the tree.
* If {@code false} all changes will be written as-is, i.e. as if they are absolute counts.
*/
protected CountUpdater directUpdater(boolean applyDeltas, CursorContext cursorContext) throws IOException {
boolean success = false;
Lock lock = this.lock.writeLock();
lock.lock();
try {
CountUpdater.CountWriter writer = applyDeltas ? new DeltaTreeWriter(() -> tree.writer(cursorContext), key -> readCountFromTree(key, cursorContext), layout, maxCacheSize) : new TreeWriter(tree.writer(cursorContext));
CountUpdater updater = new CountUpdater(writer, lock);
success = true;
return updater;
} finally {
if (!success) {
lock.unlock();
}
}
}
use of org.neo4j.index.internal.gbptree.Writer in project neo4j by neo4j.
the class IdRangeMarkerTest method shouldCloseWriterOnClose.
@Test
void shouldCloseWriterOnClose() throws IOException {
// when
Writer writer = mock(Writer.class);
try (IdRangeMarker marker = new IdRangeMarker(idsPerEntry, layout, writer, mock(Lock.class), mock(ValueMerger.class), true, new AtomicBoolean(), 1, new AtomicLong(0), true, NO_MONITOR)) {
verify(writer, never()).close();
}
// then
verify(writer).close();
}
Aggregations