use of org.neo4j.index.internal.gbptree.RawBytes in project neo4j by neo4j.
the class BlockEntryStreamMergerTest method shouldMergePartsIntoOneWithSampling.
@Test
void shouldMergePartsIntoOneWithSampling() throws Exception {
// given
List<BlockEntryCursor<RawBytes, RawBytes>> parts = buildParts(random, layout, allData);
// when
try (BlockEntryStreamMerger<RawBytes, RawBytes> merger = new BlockEntryStreamMerger<>(parts, layout, layout, NOT_CANCELLABLE, BATCH_SIZE, QUEUE_SIZE)) {
Future<Void> t2Future = t2.execute(merger);
// then
assertMergedPartStream(allData, merger);
t2Future.get();
IndexSample sample = merger.buildIndexSample();
assertThat(sample.sampleSize()).isEqualTo(allData.size());
assertThat(sample.indexSize()).isEqualTo(allData.size());
assertThat(sample.uniqueValues()).isEqualTo(countUniqueKeys(allData));
}
}
use of org.neo4j.index.internal.gbptree.RawBytes in project neo4j by neo4j.
the class BlockEntryStreamMergerTest method shouldStopMergingWhenCancelled.
@Test
void shouldStopMergingWhenCancelled() throws Exception {
// given
List<BlockEntryCursor<RawBytes, RawBytes>> parts = buildParts(random, layout, allData, 4, rng -> QUEUE_SIZE * BATCH_SIZE);
// when
AtomicBoolean cancelled = new AtomicBoolean();
try (BlockEntryStreamMerger<RawBytes, RawBytes> merger = new BlockEntryStreamMerger<>(parts, layout, null, cancelled::get, BATCH_SIZE, QUEUE_SIZE)) {
// start the merge and wait for it to fill up the queue to the brim before halting it
Future<Void> invocation = t2.execute(merger);
t2.get().waitUntilWaiting(wait -> wait.isAt(BlockEntryStreamMerger.class, "call"));
cancelled.set(true);
invocation.get();
// then we know how many items we should have gotten, and no more after that
assertThat(countEntries(merger)).isEqualTo(QUEUE_SIZE * BATCH_SIZE);
}
}
Aggregations