当前位置: 首页>>代码示例>>Java>>正文


Java Mode类代码示例

本文整理汇总了Java中org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode的典型用法代码示例。如果您正苦于以下问题:Java Mode类的具体用法?Java Mode怎么用?Java Mode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Mode类属于org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator包,在下文中一共展示了Mode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: partial1ModeIntKeysDefaultParams

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void partial1ModeIntKeysDefaultParams() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  checkIntermediateResultInspector(resultInspector);

  State state = (State) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] {new IntWritable(1)});
  eval.iterate(state, new Object[] {new IntWritable(2)});

  Object result = eval.terminatePartial(state);
  Assert.assertNotNull(result);
  Assert.assertTrue(result instanceof List);
  List<?> r = (List<?>) result;
  Assert.assertEquals(r.size(), 3);
  Assert.assertEquals(((IntWritable) r.get(0)).get(), SketchEvaluator.DEFAULT_LG_K);
  Assert.assertEquals(((Text) r.get(1)).toString(), SketchEvaluator.DEFAULT_HLL_TYPE.toString());
  HllSketch resultSketch = HllSketch.heapify(Memory.wrap(((BytesWritable) r.get(2)).getBytes()));
  Assert.assertEquals(resultSketch.getEstimate(), 2.0, 0.01);

  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:25,代码来源:DataToSketchUDAFTest.java

示例2: partial1ModeGetStateBeforeInit

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void partial1ModeGetStateBeforeInit() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToSketchUDAF().getEvaluator(info);

  State state = (State) eval.getNewAggregationBuffer();
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  checkIntermediateResultInspector(resultInspector);

  eval.iterate(state, new Object[] {new IntWritable(1)});
  eval.iterate(state, new Object[] {new IntWritable(2)});

  Object result = eval.terminatePartial(state);
  Assert.assertNotNull(result);
  Assert.assertTrue(result instanceof List);
  List<?> r = (List<?>) result;
  Assert.assertEquals(r.size(), 3);
  Assert.assertEquals(((IntWritable) r.get(0)).get(), SketchEvaluator.DEFAULT_LG_K);
  Assert.assertEquals(((Text) r.get(1)).toString(), SketchEvaluator.DEFAULT_HLL_TYPE.toString());
  HllSketch resultSketch = HllSketch.wrap(Memory.wrap(((BytesWritable) r.get(2)).getBytes()));
  Assert.assertEquals(resultSketch.getEstimate(), 2.0, 0.01);

  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:26,代码来源:DataToSketchUDAFTest.java

示例3: completeModeIntKeysDefaultParams

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void completeModeIntKeysDefaultParams() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.COMPLETE, inspectors);
  checkFinalResultInspector(resultInspector);

  State state = (State) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] {new IntWritable(1)});
  eval.iterate(state, new Object[] {new IntWritable(2)});

  Object result = eval.terminate(state);
  Assert.assertNotNull(result);
  Assert.assertTrue(result instanceof BytesWritable);
  HllSketch resultSketch = HllSketch.heapify(Memory.wrap(((BytesWritable) result).getBytes()));
  Assert.assertEquals(resultSketch.getEstimate(), 2.0, 0.01);

  eval.reset(state);
  result = eval.terminate(state);
  Assert.assertNull(result);

  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:25,代码来源:DataToSketchUDAFTest.java

示例4: iterateTerminatePartial

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void iterateTerminatePartial() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new UnionStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsState<String> state = (ItemsState<String>) eval.getNewAggregationBuffer();
  state.init(256);
  state.update("a");

  ItemsSketch<String> sketch = new ItemsSketch<String>(256);
  sketch.update("b");

  eval.iterate(state, new Object[] { new BytesWritable(sketch.toByteArray(serDe)) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), serDe);
  Assert.assertEquals(resultSketch.getStreamLength(), 2);
  Assert.assertEquals(resultSketch.getNumActiveItems(), 2);
  Assert.assertEquals(resultSketch.getEstimate("a"), 1);
  Assert.assertEquals(resultSketch.getEstimate("b"), 1);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:UnionStringsSketchUDAFTest.java

示例5: mergeTerminate

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void mergeTerminate() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new UnionStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL2, inspectors);
  checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsState<String> state = (ItemsState<String>) eval.getNewAggregationBuffer();
  state.init(256);
  state.update("a");

  ItemsSketch<String> sketch = new ItemsSketch<String>(256);
  sketch.update("b");

  eval.merge(state, new BytesWritable(sketch.toByteArray(serDe)));

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), serDe);
  Assert.assertEquals(resultSketch.getStreamLength(), 2);
  Assert.assertEquals(resultSketch.getNumActiveItems(), 2);
  Assert.assertEquals(resultSketch.getEstimate("a"), 1);
  Assert.assertEquals(resultSketch.getEstimate("b"), 1);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:UnionStringsSketchUDAFTest.java

示例6: iterateTerminatePartial

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void iterateTerminatePartial() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsState<String> state = (ItemsState<String>) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("a"), new IntWritable(256) });
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("b"), new IntWritable(256) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), serDe);
  Assert.assertEquals(resultSketch.getStreamLength(), 2);
  Assert.assertEquals(resultSketch.getNumActiveItems(), 2);
  Assert.assertEquals(resultSketch.getEstimate("a"), 1);
  Assert.assertEquals(resultSketch.getEstimate("b"), 1);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:22,代码来源:DataToStringsSketchUDAFTest.java

示例7: mergeTerminate

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void mergeTerminate() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL2, new ObjectInspector[] { binaryInspector });
  checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsState<String> state = (ItemsState<String>) eval.getNewAggregationBuffer();
  state.init(256);
  state.update("a");

  ItemsSketch<String> sketch = new ItemsSketch<String>(256);
  sketch.update("b");

  eval.merge(state, new BytesWritable(sketch.toByteArray(serDe)));

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), serDe);
  Assert.assertEquals(resultSketch.getStreamLength(), 2);
  Assert.assertEquals(resultSketch.getNumActiveItems(), 2);
  Assert.assertEquals(resultSketch.getEstimate("a"), 1);
  Assert.assertEquals(resultSketch.getEstimate("b"), 1);
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:27,代码来源:DataToStringsSketchUDAFTest.java

示例8: partia1ModelDefaultKDowsizeInput

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的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

示例9: partia1ModelGivenK

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的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

示例10: partial2Mode

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的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

示例11: finalMode

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的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

示例12: partial1ModeDefaultK

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void partial1ModeDefaultK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsUnionState<String> state = (ItemsUnionState<String>) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("a") });
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("b") });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), comparator, serDe);
  Assert.assertEquals(resultSketch.getK(), 128);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), "a");
  Assert.assertEquals(resultSketch.getMaxValue(), "b");
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:22,代码来源:DataToStringsSketchUDAFTest.java

示例13: partial1ModeGivenK

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void partial1ModeGivenK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.PARTIAL1, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsUnionState<String> state = (ItemsUnionState<String>) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("a"), new IntWritable(256) });
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("b"), new IntWritable(256) });

  BytesWritable bytes = (BytesWritable) eval.terminatePartial(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), comparator, serDe);
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), "a");
  Assert.assertEquals(resultSketch.getMaxValue(), "b");
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:22,代码来源:DataToStringsSketchUDAFTest.java

示例14: completeModeDefaultK

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void completeModeDefaultK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.COMPLETE, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsUnionState<String> state = (ItemsUnionState<String>) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("a") });
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("b") });

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), comparator, serDe);
  Assert.assertEquals(resultSketch.getK(), 128);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), "a");
  Assert.assertEquals(resultSketch.getMaxValue(), "b");
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:22,代码来源:DataToStringsSketchUDAFTest.java

示例15: completeModeGivenK

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode; //导入依赖的package包/类
@Test
public void completeModeGivenK() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector, intInspector };
  GenericUDAFParameterInfo info = new SimpleGenericUDAFParameterInfo(inspectors, false, false);
  GenericUDAFEvaluator eval = new DataToStringsSketchUDAF().getEvaluator(info);
  ObjectInspector resultInspector = eval.init(Mode.COMPLETE, inspectors);
  DataToDoublesSketchUDAFTest.checkResultInspector(resultInspector);

  @SuppressWarnings("unchecked")
  ItemsUnionState<String> state = (ItemsUnionState<String>) eval.getNewAggregationBuffer();
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("a"), new IntWritable(256) });
  eval.iterate(state, new Object[] { new org.apache.hadoop.io.Text("b"), new IntWritable(256) });

  BytesWritable bytes = (BytesWritable) eval.terminate(state);
  ItemsSketch<String> resultSketch = ItemsSketch.getInstance(Memory.wrap(bytes.getBytes()), comparator, serDe);
  Assert.assertEquals(resultSketch.getK(), 256);
  Assert.assertEquals(resultSketch.getRetainedItems(), 2);
  Assert.assertEquals(resultSketch.getMinValue(), "a");
  Assert.assertEquals(resultSketch.getMaxValue(), "b");
  eval.close();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:22,代码来源:DataToStringsSketchUDAFTest.java


注:本文中的org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。