use of org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal in project sketches-core by DataSketches.
the class ConcurrentDirectQuickSelectSketchTest method checkRebuild.
@Test
public void checkRebuild() {
int lgK = 9;
int k = 1 << lgK;
int u = 4 * k;
boolean useMem = true;
SharedLocal sl = new SharedLocal(lgK, lgK, useMem);
UpdateSketch shared = sl.shared;
UpdateSketch local = sl.local;
assertTrue(local.isEmpty());
for (int i = 0; i < u; i++) {
local.update(i);
}
waitForBgPropagationToComplete(shared);
assertFalse(local.isEmpty());
assertTrue(local.getEstimate() > 0.0);
assertTrue(shared.getRetainedEntries(false) >= k);
shared.rebuild();
assertEquals(shared.getRetainedEntries(false), k);
assertEquals(shared.getRetainedEntries(true), k);
local.rebuild();
assertEquals(shared.getRetainedEntries(false), k);
assertEquals(shared.getRetainedEntries(true), k);
}
use of org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal in project sketches-core by DataSketches.
the class ConcurrentDirectQuickSelectSketchTest method checkExactModeMemoryArr.
@Test
public void checkExactModeMemoryArr() {
int lgK = 12;
int k = 1 << lgK;
int u = k;
boolean useMem = true;
SharedLocal sl = new SharedLocal(lgK, lgK, useMem);
UpdateSketch shared = sl.shared;
UpdateSketch local = sl.local;
assertTrue(local.isEmpty());
for (int i = 0; i < u; i++) {
local.update(i);
}
waitForBgPropagationToComplete(shared);
assertEquals(local.getEstimate(), u, 0.0);
assertEquals(shared.getRetainedEntries(false), u);
}
use of org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal in project sketches-core by DataSketches.
the class ConcurrentDirectQuickSelectSketchTest method checkEstModeNativeMemory.
@Test
public void checkEstModeNativeMemory() {
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);
}
use of org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal in project sketches-core by DataSketches.
the class ConcurrentDirectQuickSelectSketchTest method checkWrapIllegalFamilyID_direct.
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapIllegalFamilyID_direct() {
int lgK = 9;
boolean useMem = true;
SharedLocal sl = new SharedLocal(lgK, lgK, useMem);
// corrupt the Sketch ID byte
sl.wmem.putByte(FAMILY_BYTE, (byte) 0);
// try to wrap the corrupted mem
DirectQuickSelectSketch.writableWrap(sl.wmem, DEFAULT_UPDATE_SEED);
}
use of org.apache.datasketches.theta.ConcurrentHeapQuickSelectSketchTest.SharedLocal in project sketches-core by DataSketches.
the class ConcurrentDirectQuickSelectSketchTest method checkResetAndStartingSubMultiple.
@Test
public void checkResetAndStartingSubMultiple() {
int lgK = 9;
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 = 4 * k;
for (int i = 0; i < u; i++) {
local.update(i);
}
waitForBgPropagationToComplete(shared);
assertFalse(local.isEmpty());
assertTrue(shared.getRetainedEntries(false) >= k);
assertTrue(local.getThetaLong() < Long.MAX_VALUE);
shared.reset();
local.reset();
assertTrue(local.isEmpty());
assertEquals(shared.getRetainedEntries(false), 0);
assertEquals(local.getEstimate(), 0.0, 0.0);
assertEquals(local.getThetaLong(), Long.MAX_VALUE);
}
Aggregations