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


Java GenericUDTF类代码示例

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


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

示例1: initialize

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@Override
public StructObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    try {
        // Extract a collector for LogisticRegressionDataGeneratorUDTF
        Field collector = GenericUDTF.class.getDeclaredField("collector");
        collector.setAccessible(true);
        udtf.setCollector((Collector) collector.get(this));

        // To avoid HadoopUtils#getTaskId()
        Class<?> clazz = udtf.getClass();
        Field rnd1 = clazz.getDeclaredField("rnd1");
        Field rnd2 = clazz.getDeclaredField("rnd2");
        Field r_seed = clazz.getDeclaredField("r_seed");
        r_seed.setAccessible(true);
        final long seed = r_seed.getLong(udtf) + (int) Thread.currentThread().getId();
        rnd1.setAccessible(true);
        rnd2.setAccessible(true);
        rnd1.set(udtf, new Random(seed));
        rnd2.set(udtf, new Random(seed + 1));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return udtf.initialize(argOIs);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:25,代码来源:LogisticRegressionDataGeneratorUDTFWrapper.java

示例2: normalCase

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings({ "deprecation", "unchecked" })
@Test
public void normalCase() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector };
  GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
  ObjectInspector resultInspector = func.initialize(inspectors);
  checkResultInspector(resultInspector);
  ArrayOfDoublesUpdatableSketch sketch = new ArrayOfDoublesUpdatableSketchBuilder().setNumberOfValues(2).build();
  sketch.update(1, new double[] {1, 2});
  sketch.update(2, new double[] {1, 2});
  MockCollector collector = new MockCollector();
  func.setCollector(collector);
  func.process(new Object[] {new BytesWritable(sketch.toByteArray())});
  Assert.assertEquals(collector.list.size(), 2);
  Assert.assertEquals(((Object[]) collector.list.get(0)).length, 1);
  Assert.assertEquals(((List<Double>) ((Object[]) collector.list.get(0))[0]), Arrays.asList(1.0, 2.0));
  Assert.assertEquals(((List<Double>) ((Object[]) collector.list.get(1))[0]), Arrays.asList(1.0, 2.0));
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:19,代码来源:ArrayOfDoublesSketchToValuesUDTFTest.java

示例3: evaluate

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
private static List<Object> evaluate(final GenericUDTF udtf, final Object... ins) throws HiveException {
	final List<Object> out = new ArrayList<>();
	udtf.setCollector(new Collector() {
		@Override
		public void collect(Object input) throws HiveException {
			out.add(input);
		}
	});
	for (Object in : ins)
		udtf.process(new Object[] { in });
	return out;
}
 
开发者ID:CyberAgent,项目名称:hive-jq-udtf,代码行数:13,代码来源:JsonQueryUDTFTest.java

示例4: initializeTooFewInspectors

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeTooFewInspectors() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:GetFrequentItemsFromStringsSketchUDTFTest.java

示例5: initializeTooManyInspectors

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeTooManyInspectors() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, stringInspector, stringInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:GetFrequentItemsFromStringsSketchUDTFTest.java

示例6: initializeWrongCategoryArg1

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongCategoryArg1() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { structInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:GetFrequentItemsFromStringsSketchUDTFTest.java

示例7: initializeWrongCategoryArg2

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongCategoryArg2() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, structInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:GetFrequentItemsFromStringsSketchUDTFTest.java

示例8: initializeWrongTypeArg1

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongTypeArg1() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector, stringInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:GetFrequentItemsFromStringsSketchUDTFTest.java

示例9: initializeWrongTypeArg2

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongTypeArg2() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, binaryInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:GetFrequentItemsFromStringsSketchUDTFTest.java

示例10: initializeNoInspectors

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
 public void initializeNoInspectors() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:ArrayOfDoublesSketchToValuesUDTFTest.java

示例11: initializeTooManyInspectors

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
 public void initializeTooManyInspectors() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, binaryInspector };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:ArrayOfDoublesSketchToValuesUDTFTest.java

示例12: initializeWrongCategory

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentTypeException.class)
 public void initializeWrongCategory() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { structInspector };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:ArrayOfDoublesSketchToValuesUDTFTest.java

示例13: initializeWrongType

import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentTypeException.class)
 public void initializeWrongType() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:8,代码来源:ArrayOfDoublesSketchToValuesUDTFTest.java


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