• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DoublesSketch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.yahoo.sketches.quantiles.DoublesSketch的典型用法代码示例。如果您正苦于以下问题:Java DoublesSketch类的具体用法?Java DoublesSketch怎么用?Java DoublesSketch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DoublesSketch类属于com.yahoo.sketches.quantiles包,在下文中一共展示了DoublesSketch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: _apply

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Override
public Iterable<Element> _apply(final String line) {
    final List<Element> elements = new ArrayList<>();
    for (int i = 0; i < 1000; i++) {
        final UpdateDoublesSketch doublesSketch = DoublesSketch.builder().build();
        doublesSketch.update(RANDOM.nextGaussian());
        final Edge edge = new Edge.Builder()
                .group("red")
                .source("A")
                .dest("B")
                .property("doublesSketch", doublesSketch)
                .build();
        elements.add(edge);
    }
    return elements;
}
 
开发者ID:gchq,项目名称:gaffer-doc,代码行数:17,代码来源:DoublesSketchElementGenerator.java


示例2: ProducerStats

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
public ProducerStats(PulsarClientImpl pulsarClient, ProducerConfiguration conf, ProducerImpl producer) {
    this.pulsarClient = pulsarClient;
    this.statsIntervalSeconds = pulsarClient.getConfiguration().getStatsIntervalSeconds();
    this.producer = producer;
    numMsgsSent = new LongAdder();
    numBytesSent = new LongAdder();
    numSendFailed = new LongAdder();
    numAcksReceived = new LongAdder();
    totalMsgsSent = new LongAdder();
    totalBytesSent = new LongAdder();
    totalSendFailed = new LongAdder();
    totalAcksReceived = new LongAdder();
    ds = DoublesSketch.builder().build(256);
    dec = new DecimalFormat("0.000");
    throughputFormat = new DecimalFormat("0.00");
    init(conf);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:18,代码来源:ProducerStats.java


示例3: evaluate

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
/**
 * Convert a given column from a given ArrayOfDoublesSketch to a quantiles DoublesSketch
 * @param serializedSketch ArrayOfDoublesSketch in as serialized binary
 * @param column 1-based column number
 * @param k parameter that determines the accuracy and size of the quantiles sketch
 * @return serialized DoublesSketch
 */
public BytesWritable evaluate(final BytesWritable serializedSketch, final int column,
    final int k) {
  if (serializedSketch == null) { return null; }
  final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketches.wrapSketch(
      Memory.wrap(serializedSketch.getBytes()));
  if (column < 1) {
    throw new IllegalArgumentException("Column number must be greater than zero. Received: "
        + column);
  }
  if (column > sketch.getNumValues()) {
    throw new IllegalArgumentException("Column number " + column
        + " is out of range. The given sketch has "
        + sketch.getNumValues() + " columns");
  }
  final DoublesSketchBuilder builder = DoublesSketch.builder();
  if (k > 0) {
    builder.setK(k);
  }
  final UpdateDoublesSketch qs = builder.build();
  final ArrayOfDoublesSketchIterator it = sketch.iterator();
  while (it.next()) {
    qs.update(it.getValues()[column - 1]);
  }
  return new BytesWritable(qs.compact().toByteArray());
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:33,代码来源:ArrayOfDoublesSketchToQuantilesSketchUDF.java


示例4: partia1ModelDefaultKDowsizeInput

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void partia1ModelDefaultKDowsizeInput() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new UnionDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();

  UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(256).build();
  sketch1.update(1.0);
  eval.iterate(state, new Object[] { new BytesWritable(sketch1.toByteArray()) });

  UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(256).build();
  sketch2.update(2.0);
  eval.iterate(state, new Object[] { new BytesWritable(sketch2.toByteArray()) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 128);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:UnionDoublesSketchUDAFTest.java


示例5: partia1ModelGivenK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void partia1ModelGivenK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new UnionDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();

  UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(256).build();
  sketch1.update(1.0);
  eval.iterate(state, new Object[] { new BytesWritable(sketch1.toByteArray()), new IntWritable(256) });

  UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(256).build();
  sketch2.update(2.0);
  eval.iterate(state, new Object[] { new BytesWritable(sketch2.toByteArray()), new IntWritable(256) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:UnionDoublesSketchUDAFTest.java


示例6: partial2Mode

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void partial2Mode() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new UnionDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL2, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();

  UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(256).build();
  sketch1.update(1.0);
  eval.merge(state, new BytesWritable(sketch1.toByteArray()));

  UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(256).build();
  sketch2.update(2.0);
  eval.merge(state, new BytesWritable(sketch2.toByteArray()));

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:UnionDoublesSketchUDAFTest.java


示例7: finalMode

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void finalMode() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new UnionDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.FINAL, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();

  UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(256).build();
  sketch1.update(1.0);
  eval.merge(state, new BytesWritable(sketch1.toByteArray()));

  UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(256).build();
  sketch2.update(2.0);
  eval.merge(state, new BytesWritable(sketch2.toByteArray()));

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:UnionDoublesSketchUDAFTest.java


示例8: partial1ModeDefaultK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void partial1ModeDefaultK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { doubleInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new DoubleWritable(1.0) });
  eval.iterate(state, new Object[] { new DoubleWritable(2.0) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 128);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:21,代码来源:DataToDoublesSketchUDAFTest.java


示例9: partial1ModeGivenK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void partial1ModeGivenK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { doubleInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new DoubleWritable(1.0), new IntWritable(256) });
  eval.iterate(state, new Object[] { new DoubleWritable(2.0), new IntWritable(256) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:21,代码来源:DataToDoublesSketchUDAFTest.java


示例10: partial2Mode

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void partial2Mode() throws Exception {
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(new ObjectInspector[] { doubleInspector }, false, false);
  GenericUDAFEvaluator eval = new DataToDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL2, new ObjectInspector[] {binaryInspector});
  checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();

  UpdateDoublesSketch sketch1 = DoublesSketch.builder().build();
  sketch1.update(1.0);
  eval.merge(state, new BytesWritable(sketch1.toByteArray()));

  UpdateDoublesSketch sketch2 = DoublesSketch.builder().build();
  sketch2.update(2.0);
  eval.merge(state, new BytesWritable(sketch2.toByteArray()));

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:25,代码来源:DataToDoublesSketchUDAFTest.java


示例11: finalMode

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void finalMode() throws Exception {
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(new ObjectInspector[] { doubleInspector }, false, false);
  GenericUDAFEvaluator eval = new DataToDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.FINAL, new ObjectInspector[] {binaryInspector});
  checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();

  UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(256).build();
  sketch1.update(1.0);
  eval.merge(state, new BytesWritable(sketch1.toByteArray()));

  UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(256).build();
  sketch2.update(2.0);
  eval.merge(state, new BytesWritable(sketch2.toByteArray()));

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:26,代码来源:DataToDoublesSketchUDAFTest.java


示例12: completeModeDefaultK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void completeModeDefaultK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { doubleInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.COMPLETE, inspectors);
  checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new DoubleWritable(1.0) });
  eval.iterate(state, new Object[] { new DoubleWritable(2.0) });

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 128);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:21,代码来源:DataToDoublesSketchUDAFTest.java


示例13: completeModeGivenK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void completeModeGivenK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { doubleInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToDoublesSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.COMPLETE, inspectors);
  checkResultInspector(resultInspector);

  DoublesUnionState state = (DoublesUnionState) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new DoubleWritable(1.0), new IntWritable(256) });
  eval.iterate(state, new Object[] { new DoubleWritable(2.0), new IntWritable(256) });

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  DoublesSketch resultSketch = DoublesSketch.wrap(Memory.wrap(bytes.getBytes()));
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), 1.0);
  Assert.assertEquals(resultSketch.getMaxValue(), 2.0);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:21,代码来源:DataToDoublesSketchUDAFTest.java


示例14: nonEmptySketchWithTwoColumnsExplicitK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void nonEmptySketchWithTwoColumnsExplicitK() {
  int k = 256;
  ArrayOfDoublesUpdatableSketch sketch = new ArrayOfDoublesUpdatableSketchBuilder().setNumberOfValues(2).build();
  sketch.update(1, new double[] {1.0, 2.0});
  sketch.update(2, new double[] {10.0, 20.0});
  BytesWritable result = new ArrayOfDoublesSketchToQuantilesSketchUDF().evaluate(
    new BytesWritable(sketch.compact().toByteArray()),
    2,
    k
  );
  Assert.assertNotNull(result);
  DoublesSketch qs = DoublesSketch.wrap(Memory.wrap(result.getBytes()));
  Assert.assertFalse(qs.isEmpty());
  Assert.assertEquals(qs.getK(), k);
  Assert.assertEquals(qs.getMinValue(), 2.0);
  Assert.assertEquals(qs.getMaxValue(), 20.0);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:19,代码来源:ArrayOfDoublesSketchToQuantilesSketchUDFTest.java


示例15: exec

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Override
public Tuple exec(final Tuple input) throws IOException {
  if (input.size() < 2) {
    throw new IllegalArgumentException(
        "expected two or more inputs: sketch and list of split points");
  }

  if (!(input.get(0) instanceof DataByteArray)) {
    throw new IllegalArgumentException("expected a DataByteArray as a sketch, got "
        + input.get(0).getClass().getSimpleName());
  }
  final DataByteArray dba = (DataByteArray) input.get(0);
  final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(dba.get()));

  final double[] splitPoints = new double[input.size() - 1];
  for (int i = 1; i < input.size(); i++) {
    if (!(input.get(i) instanceof Double)) {
      throw new IllegalArgumentException("expected a double value as a split point, got "
          + input.get(i).getClass().getSimpleName());
    }
    splitPoints[i - 1] = (double) input.get(i);
  }
  return Util.doubleArrayToTuple(sketch.getPMF(splitPoints));
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:25,代码来源:GetPmfFromDoublesSketch.java


示例16: exec

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Override
public Double exec(final Tuple input) throws IOException {
  if (input.size() != 2) {
    throw new IllegalArgumentException("expected two inputs: sketch and fraction");
  }

  if (!(input.get(0) instanceof DataByteArray)) {
    throw new IllegalArgumentException("expected a DataByteArray as a sketch, got "
        + input.get(0).getClass().getSimpleName());
  }
  final DataByteArray dba = (DataByteArray) input.get(0);
  final DoublesSketch sketch = DoublesSketch.wrap(Memory.wrap(dba.get()));

  if (!(input.get(1) instanceof Double)) {
    throw new IllegalArgumentException("expected a double value as a fraction, got "
        + input.get(1).getClass().getSimpleName());
  }
  final double fraction = (double) input.get(1);
  return sketch.getQuantile(fraction);
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:21,代码来源:GetQuantileFromDoublesSketch.java


示例17: exec

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Override
public Double exec(final Tuple input) throws IOException {
  if (input.size() != 2) {
    throw new IllegalArgumentException("expected two inputs: sketch and pecentile");
  }

  final DataByteArray dba = (DataByteArray) input.get(0);
  final Sketch<DoubleSummary> sketch = Sketches.heapifySketch(Memory.wrap(dba.get()));

  final double percentile = (double) input.get(1);
  if ((percentile < 0) || (percentile > 100)) {
    throw new IllegalArgumentException("percentile must be between 0 and 100");
  }

  final UpdateDoublesSketch qs = DoublesSketch.builder().setK(QUANTILES_SKETCH_SIZE).build();
  final SketchIterator<DoubleSummary> it = sketch.iterator();
  while (it.next()) {
    qs.update(it.getSummary().getValue());
  }
  return qs.getQuantile(percentile / 100);
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:22,代码来源:DoubleSummarySketchToPercentile.java


示例18: algebraicIntermediateFinalNormalCase

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void algebraicIntermediateFinalNormalCase() throws Exception {
  EvalFunc<Tuple> func = new DataToDoublesSketch.IntermediateFinal();
  DataBag bag = bagFactory.newDefaultBag();

  { // this is to simulate an output from Initial
    DataBag innerBag = bagFactory.newDefaultBag();
    innerBag.add(tupleFactory.newTuple(1.0));
    bag.add(tupleFactory.newTuple(innerBag));
  }

  { // this is to simulate an output from a prior call of IntermediateFinal
    UpdateDoublesSketch qs = DoublesSketch.builder().build();
    qs.update(2.0);
    bag.add(tupleFactory.newTuple(new DataByteArray(qs.toByteArray())));
  }

  Tuple resultTuple = func.exec(tupleFactory.newTuple(bag));
  DoublesSketch sketch = getSketch(resultTuple);
  Assert.assertFalse(sketch.isEmpty());
  Assert.assertEquals(sketch.getN(), 2);
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:23,代码来源:DataToDoublesSketchTest.java


示例19: nonEmptyInputSketchWithTwoColumnsExplicitK

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
@Test
public void nonEmptyInputSketchWithTwoColumnsExplicitK() throws Exception {
  int k = 256;
  EvalFunc<DataByteArray> func = new ArrayOfDoublesSketchToQuantilesSketch(Integer.toString(k));
  ArrayOfDoublesUpdatableSketch sketch = new ArrayOfDoublesUpdatableSketchBuilder().setNumberOfValues(2).build();
  sketch.update(1, new double[] {1.0, 2.0});
  sketch.update(2, new double[] {10.0, 20.0});
  DataByteArray result = func.exec(tupleFactory.newTuple(Arrays.asList(
      new DataByteArray(sketch.compact().toByteArray()),
      2
  )));
  Assert.assertNotNull(result);
  DoublesSketch quantilesSketch = DoublesSketch.wrap(Memory.wrap(result.get()));
  Assert.assertFalse(quantilesSketch.isEmpty());
  Assert.assertEquals(quantilesSketch.getK(), k);
  Assert.assertEquals(quantilesSketch.getMinValue(), 2.0);
  Assert.assertEquals(quantilesSketch.getMaxValue(), 20.0);
}
 
开发者ID:DataSketches,项目名称:sketches-pig,代码行数:19,代码来源:ArrayOfDoublesSketchToQuantilesSketchTest.java


示例20: create

import com.yahoo.sketches.quantiles.DoublesSketch; //导入依赖的package包/类
public void create(TDoubleVector vec) {
  double[] fracs = new double[size];
  double min = Double.MAX_VALUE;
  for (int i = 0; i < size; i++) {
    fracs[i] = i / (double) size;
  }

  int maxDim = vec.getDimension();

  DoublesSketch sketches = DoublesSketch.builder().build();

  for (int dim = 0; dim < maxDim; dim++) {
    if (Math.abs(vec.get(dim)) > 10e-12) {
      sketches.update(vec.get(dim));
      min = Math.min(min, vec.get(dim));
    }
  }

  splits = sketches.getQuantiles(fracs);

  for (int dim = 0; dim < maxDim; dim++) {
    if (Math.abs(vec.get(dim)) > 10e-12) {
      counts[indexOf(vec.get(dim))]++;
      totalCount++;
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:28,代码来源:YahooSketch.java



注:本文中的com.yahoo.sketches.quantiles.DoublesSketch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Util类代码示例发布时间:2022-05-23
下一篇:
Java RepairJobDesc类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap