Search in sources :

Example 26 with SharedLocal

use of org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal in project sketches-core by DataSketches.

the class ConcurrentDirectQuickSelectSketchTest method checkEstModeMemoryArr.

@Test
public void checkEstModeMemoryArr() {
    int lgK = 12;
    int k = 1 << lgK;
    boolean useMem = true;
    SharedLocal sl = new SharedLocal(lgK, lgK, useMem);
    UpdateSketch shared = sl.shared;
    UpdateSketch local = sl.local;
    assertTrue(local.isEmpty());
    int u = 3 * k;
    for (int i = 0; i < u; i++) {
        local.update(i);
    }
    waitForBgPropagationToComplete(shared);
    double est = local.getEstimate();
    assertTrue((est < (u * 1.05)) && (est > (u * 0.95)));
    assertTrue(shared.getRetainedEntries(false) >= k);
}
Also used : SharedLocal(org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal) Test(org.testng.annotations.Test)

Aggregations

SharedLocal (org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal)26 Test (org.testng.annotations.Test)26 WritableMemory (org.apache.datasketches.memory.WritableMemory)6 Memory (org.apache.datasketches.memory.Memory)3