Java Code Examples for org.apache.hadoop.hive.ql.udf.generic.GenericUDTF#initialize()

The following examples show how to use org.apache.hadoop.hive.ql.udf.generic.GenericUDTF#initialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrayOfDoublesSketchToValuesUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 2
Source File: GetFrequentItemsFromStringsSketchUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeTooFewInspectors() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
Example 3
Source File: GetFrequentItemsFromStringsSketchUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: GetFrequentItemsFromStringsSketchUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongCategoryArg1() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { structInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
Example 5
Source File: GetFrequentItemsFromStringsSketchUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongCategoryArg2() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, structInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
Example 6
Source File: GetFrequentItemsFromStringsSketchUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongTypeArg1() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector, stringInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
Example 7
Source File: GetFrequentItemsFromStringsSketchUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
public void initializeWrongTypeArg2() throws Exception {
  ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, binaryInspector };
  GenericUDTF func = new GetFrequentItemsFromStringsSketchUDTF();
  func.initialize(inspectors);
}
 
Example 8
Source File: ArrayOfDoublesSketchToValuesUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
 public void initializeNoInspectors() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
Example 9
Source File: ArrayOfDoublesSketchToValuesUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentException.class)
 public void initializeTooManyInspectors() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { binaryInspector, binaryInspector };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
Example 10
Source File: ArrayOfDoublesSketchToValuesUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentTypeException.class)
 public void initializeWrongCategory() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { structInspector };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }
 
Example 11
Source File: ArrayOfDoublesSketchToValuesUDTFTest.java    From incubator-datasketches-hive with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test(expectedExceptions = UDFArgumentTypeException.class)
 public void initializeWrongType() throws Exception {
   ObjectInspector[] inspectors = new ObjectInspector[] { stringInspector };
   GenericUDTF func = new ArrayOfDoublesSketchToValuesUDTF();
   func.initialize(inspectors);
 }