private PrimitiveCategory elemCategory;
private int sketchSetSize = SketchSetUDAF.DEFAULT_SKETCH_SET_SIZE;
@Override
public Object evaluate(DeferredObject[] arg0) throws HiveException {
SketchSet ss = new SketchSet(sketchSetSize);
for( int i=0; i< arg0.length; ++i) {
Object listObj = arg0[i].get();
int listLen = listInspectors[i].getListLength(listObj);
for(int j=0; j< listLen; ++j ) {
Object uninspObj = listInspectors[i].getListElement(listObj, j);
switch( elemCategory) {
case STRING:
StringObjectInspector strInspector = (StringObjectInspector) listInspectors[i].getListElementObjectInspector();
String item = strInspector.getPrimitiveJavaObject(uninspObj);
ss.addItem(item);
break;
case LONG:
LongObjectInspector bigintInspector = (LongObjectInspector) listInspectors[i].getListElementObjectInspector();
long itemHash = bigintInspector.get(uninspObj);
ss.addHash( itemHash);
break;
}
}
}
switch( elemCategory) {
case STRING:
return ss.getMinHashItems();
case LONG:
return ss.getMinHashes();
default:
/// will never happen
throw new HiveException("Unexpected Element Category " + elemCategory);
}
}