Search in sources :

Example 1 with RawBytes

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));
    }
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) RawBytes(org.neo4j.index.internal.gbptree.RawBytes) Test(org.junit.jupiter.api.Test)

Example 2 with RawBytes

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);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RawBytes(org.neo4j.index.internal.gbptree.RawBytes) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 RawBytes (org.neo4j.index.internal.gbptree.RawBytes)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IndexSample (org.neo4j.kernel.api.index.IndexSample)1