in src/main/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java [107:149]
public ObjectInspector init(final Mode mode, final ObjectInspector[] parameters) throws HiveException {
super.init(mode, parameters);
this.mode_ = mode;
if ((mode == Mode.PARTIAL1) || (mode == Mode.COMPLETE)) {
// input is original data
this.keyInspector_ = (PrimitiveObjectInspector) parameters[0];
this.numValues_ = 0;
while ((this.numValues_ + 1) < parameters.length) {
if (((PrimitiveObjectInspector) parameters[this.numValues_ + 1]).getPrimitiveCategory()
!= PrimitiveCategory.DOUBLE) {
break;
}
this.numValues_++;
}
this.valuesInspectors_ = new PrimitiveObjectInspector[this.numValues_];
for (int i = 0; i < this.numValues_; i++) {
this.valuesInspectors_[i] = (PrimitiveObjectInspector) parameters[i + 1];
}
if (parameters.length > (this.numValues_ + 1)) {
this.nominalNumEntriesInspector_ = (PrimitiveObjectInspector) parameters[this.numValues_ + 1];
}
if (parameters.length > (this.numValues_ + 2)) {
this.samplingProbabilityInspector_ = (PrimitiveObjectInspector) parameters[this.numValues_ + 2];
}
} else {
// input for PARTIAL2 and FINAL is the output from PARTIAL1
this.intermediateInspector_ = (StructObjectInspector) parameters[0];
}
if ((mode == Mode.PARTIAL1) || (mode == Mode.PARTIAL2)) {
// intermediate results need to include the the nominal number of entries and number of values
return ObjectInspectorFactory.getStandardStructObjectInspector(
Arrays.asList(NOMINAL_NUM_ENTRIES_FIELD, NUM_VALUES_FIELD, SKETCH_FIELD),
Arrays.asList(
PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.INT),
PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.INT),
PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
)
);
}
// final results include just the sketch
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
}