com.yahoo.sketches.theta.Union.reset()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中com.yahoo.sketches.theta.Union.reset()方法的一些代码示例,展示了Union.reset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Union.reset()方法的具体详情如下:
包路径:com.yahoo.sketches.theta.Union
类名称:Union
方法名:reset

Union.reset介绍

[英]Resets this Union. The seed remains intact, otherwise reverts back to its virgin state.
[中]重新建立这个联盟。种子保持完整,否则会恢复到原始状态。

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
public void reset(ColumnValueSelector selector)
{
 union.reset();
 fold(selector);
}

代码示例来源:origin: org.apache.druid.extensions/druid-datasketches

@Override
public synchronized void reset()
{
 delegate.reset();
}

代码示例来源:origin: com.yahoo.bullet/bullet-core

@Override
protected void mergeUnionSketch() {
  result = unionSketch.getResult(false, null);
  unionSketch.reset();
}

代码示例来源:origin: org.apache.druid.extensions/druid-datasketches

@Override
public void reset(ColumnValueSelector selector)
{
 union.reset();
 fold(selector);
}

代码示例来源:origin: com.yahoo.bullet/bullet-core

@Override
public void reset() {
  result = null;
  updateSketch.reset();
  unionSketch.reset();
  super.reset();
}

代码示例来源:origin: DataSketches/sketches-core

@Test
public void checkUnionEarlyStop() {
 int lgK = 10;
 int k = 1<<lgK;
 int u = 4*k; //4096 + 2048 = 6144
 long v = 0;
 int trials = 10;
 UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
 UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
 Union union = SetOperation.builder().setNominalEntries(2 * k).buildUnion();
 for (int t = 0; t < trials; t++) {
  for (int i=0; i<u; i++) {
   usk1.update(i + v);
   usk2.update(i + v + u/2);
  }
  v += u + u/2;
  CompactSketch csk1 = usk1.compact(true, null);
  CompactSketch csk2 = usk2.compact(true, null);
  Sketch pwSk = PairwiseSetOperations.union(csk1, csk2, 2 * k);
  double pwEst = pwSk.getEstimate();
  union.update(csk1);
  union.update(csk2);
  CompactSketch stdSk = union.getResult(true, null);
  double stdEst = stdSk.getEstimate();
  assertEquals(pwEst, stdEst, 0.0);
  usk1.reset();
  usk2.reset();
  union.reset();
 }
}

代码示例来源:origin: DataSketches/sketches-core

@Test
public void checkHeapifyEstNoOverlapOrderedIn() {
 int lgK = 12; //4096
 int k = 1 << lgK;
 int u = 4*k;
 UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();   //2k estimating
 UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
 for (int i=0; i<u/2; i++) usk1.update(i); //2k
 for (int i=u/2; i<u; i++) usk2.update(i); //2k no overlap, exact, will force early stop
 CompactSketch cosk2 = usk2.compact(true, null);
 Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
 union.update(usk1);  //update with heap UpdateSketch
 union.update(cosk2); //update with heap Compact, Ordered input, early stop
 UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
 union.update(emptySketch); //updates with empty
 emptySketch = null;
 union.update(emptySketch); //updates with null
 testAllCompactForms(union, u, 0.05);
 Union union2 = (Union)SetOperation.heapify(Memory.wrap(union.toByteArray()));
 testAllCompactForms(union2, u, 0.05);
 union2.reset();
 assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);
}

代码示例来源:origin: DataSketches/sketches-core

cskR = PairwiseSetOperations.union(cskA, cskB, k);
assertEquals(cskC.isEmpty(), cskR.isEmpty());
union.reset();
cskR = PairwiseSetOperations.union(cskA, cskB, k);
assertEquals(cskC.isEmpty(), cskR.isEmpty());
union.reset();

代码示例来源:origin: DataSketches/sketches-core

@Test
public void checkWrapEstNoOverlapOrderedDirectIn() {
 int lgK = 12; //4096
 int k = 1 << lgK;
 int u = 4*k;
 UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();   //2k estimating
 UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
 for (int i=0; i<u/2; i++) usk1.update(i);  //2k estimating
 for (int i=u/2; i<u; i++) usk2.update(i);  //2k no overlap, exact, will force early stop
 WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
 CompactSketch cosk2 = usk2.compact(true, cskMem2); //ordered, loads the cskMem2 as ordered
 Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
 union.update(usk1);        //updates with heap UpdateSketch
 union.update(cosk2);       //updates with direct CompactSketch, ordered, use early stop
 UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
 union.update(emptySketch); //updates with empty sketch
 emptySketch = null;
 union.update(emptySketch); //updates with null sketch
 testAllCompactForms(union, u, 0.05);
 Union union2 = (Union)SetOperation.heapify(Memory.wrap(union.toByteArray()));
 testAllCompactForms(union2, u, 0.05);
 union2.reset();
 assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);
}

代码示例来源:origin: DataSketches/sketches-core

@Test
public void checkHeapifyEstNoOverlapOrderedMemIn() {
 int lgK = 12; //4096
 int k = 1 << lgK;
 int u = 4*k;
 UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();   //2k estimating
 UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
 for (int i=0; i<u/2; i++) usk1.update(i);  //2k estimating
 for (int i=u/2; i<u; i++) usk2.update(i);  //2k no overlap, exact, will force early stop
 WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
 usk2.compact(true, cskMem2); //ordered, loads the cskMem2 as ordered
 Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
 union.update(usk1);        //updates with heap UpdateSketch
 union.update(cskMem2);     //updates with direct CompactSketch, ordered, use early stop
 UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
 union.update(emptySketch); //updates with empty sketch
 emptySketch = null;
 union.update(emptySketch); //updates with null sketch
 testAllCompactForms(union, u, 0.05);
 Union union2 = (Union)SetOperation.heapify(Memory.wrap(union.toByteArray()));
 testAllCompactForms(union2, u, 0.05);
 union2.reset();
 assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);
}

代码示例来源:origin: DataSketches/sketches-core

@Test
public void checkHeapifyEstNoOverlapUnorderedMemIn() {
 int lgK = 12; //4096
 int k = 1 << lgK;
 int u = 4*k;
 UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();   //2k estimating
 UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
 for (int i=0; i<u/2; i++) usk1.update(i);  //2k estimating
 for (int i=u/2; i<u; i++) usk2.update(i);  //2k no overlap, exact, will force early stop
 WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
 usk2.compact(false, cskMem2); //unordered, loads the cskMem2 as unordered
 Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
 union.update(usk1);        //updates with heap UpdateSketch
 union.update(cskMem2);     //updates with direct CompactSketch, ordered, use early stop
 UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
 union.update(emptySketch); //updates with empty sketch
 emptySketch = null;
 union.update(emptySketch); //updates with null sketch
 testAllCompactForms(union, u, 0.05);
 Union union2 = (Union)SetOperation.heapify(Memory.wrap(union.toByteArray()));
 testAllCompactForms(union2, u, 0.05);
 union2.reset();
 assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);
}

代码示例来源:origin: DataSketches/sketches-core

@Test
public void checkWrapEstNoOverlapOrderedIn() {
 int lgK = 12; //4096
 int k = 1 << lgK;
 int u = 4*k;
 UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();   //2k estimating
 UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
 for (int i=0; i<(u/2); i++)
  {
  usk1.update(i); //2k estimating
 }
 for (int i=u/2; i<u; i++)
  {
  usk2.update(i); //2k no overlap, exact, will force early stop
 }
 CompactSketch cosk2 = usk2.compact(true, null);
 WritableMemory uMem = WritableMemory.wrap(new byte[getMaxUnionBytes(k)]);
 Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uMem);
 union.update(usk1);  //update with heap UpdateSketch
 union.update(cosk2); //update with heap Compact, Ordered input, early stop
 UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
 union.update(emptySketch); //updates with empty
 emptySketch = null;
 union.update(emptySketch); //updates with null
 testAllCompactForms(union, u, 0.05);
 Union union2 = Sketches.wrapUnion(WritableMemory.wrap(union.toByteArray()));
 testAllCompactForms(union2, u, 0.05);
 union2.reset();
 assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);
}

代码示例来源:origin: DataSketches/sketches-core

union2.reset();
assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);

代码示例来源:origin: DataSketches/sketches-core

union2.reset();
assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);

代码示例来源:origin: DataSketches/sketches-core

union2.reset();
assertEquals(union2.getResult(true, null).getEstimate(), 0.0, 0.0);

相关文章