@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { if (arguments[0].get() == null || arguments[1].get() == null) { return null; } String str = ObjectInspectorUtils.copyToStandardJavaObject( arguments[0].get(), strObjectInspector).toString(); if (set == null) { String filePath = (String)ObjectInspectorUtils.copyToStandardJavaObject( arguments[1].get(), fileObjectInspector); loadFromFile(filePath); } return set.contains(str); }
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { if (arguments[0].get() == null || arguments[1].get() == null) { return null; } String str = ObjectInspectorUtils.copyToStandardJavaObject( arguments[0].get(), strObjectInspector).toString(); if (set == null) { String filePath = (String)ObjectInspectorUtils.copyToStandardJavaObject( arguments[1].get(), fileObjectInspector); loadFromFile(filePath); } return set.contains(str); }
private Timestamp evaluateCastToTimestamp(ExprNodeDesc expr) throws HiveException { ExprNodeGenericFuncDesc expr2 = (ExprNodeGenericFuncDesc) expr; ExprNodeEvaluator evaluator = ExprNodeEvaluatorFactory.get(expr2); ObjectInspector output = evaluator.initialize(null); Object constant = evaluator.evaluate(null); Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output); if (!(java instanceof Timestamp)) { throw new HiveException("Udf: failed to convert to timestamp"); } Timestamp ts = (Timestamp) java; return ts; }
private Timestamp evaluateCastToTimestamp(ExprNodeDesc expr) throws HiveException { ExprNodeGenericFuncDesc expr2 = (ExprNodeGenericFuncDesc) expr; ExprNodeEvaluator evaluator = ExprNodeEvaluatorFactory.get(expr2); ObjectInspector output = evaluator.initialize(null); Object constant = evaluator.evaluate(null); Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output); if (!(java instanceof org.apache.hadoop.hive.common.type.Timestamp)) { throw new HiveException("Udf: failed to convert to timestamp"); } return ((org.apache.hadoop.hive.common.type.Timestamp) java).toSqlTimestamp(); }
Object val = ObjectInspectorUtils.copyToStandardJavaObject(args[0], inputOI); try { if (val instanceof Byte || val instanceof Character || val instanceof Short) {
ObjectInspector output = evaluator.initialize(childoi); Object constant = evaluator.evaluate(null); Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output); return new ExprNodeConstantDesc(exprDesc.getTypeInfo(), java);
ObjectInspector output = evaluator.initialize(childoi); Object constant = evaluator.evaluate(null); Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output); return new ExprNodeConstantDesc(exprDesc.getTypeInfo(), java);
TypeInfo structType = TypeInfoUtils.getTypeInfoFromObjectInspector(coi); return new ExprNodeConstantDesc(structType, ObjectInspectorUtils.copyToStandardJavaObject(o, coi)); } else if (!PrimitiveObjectInspectorUtils.isPrimitiveJavaClass(clz)) { if (LOG.isErrorEnabled()) {
Object value = ObjectInspectorUtils.copyToStandardJavaObject(coi.getWritableConstantValue(), coi);
TypeInfo structType = TypeInfoUtils.getTypeInfoFromObjectInspector(coi); return new ExprNodeConstantDesc(structType, ObjectInspectorUtils.copyToStandardJavaObject(o, coi)); } else if (!PrimitiveObjectInspectorUtils.isPrimitiveJavaClass(clz)) { if (LOG.isErrorEnabled()) {
Object value = ObjectInspectorUtils.copyToStandardJavaObject(coi.getWritableConstantValue(), coi);
Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output);
Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output);
public List<Object> evaluate(List<Object> uninspArray) { List<Object> newList = new ArrayList<Object>(); for (Object uninsp : uninspArray) { LOG.info("Uninspected = " + uninsp); Object stdObject = ObjectInspectorUtils.copyToStandardJavaObject(uninsp, fromInspector); Object castedObject = coerceObject(stdObject); newList.add(castedObject); } return newList; }
private void addVectorMap(Object mapObj, VectorMapAggBuffer myagg, MapObjectInspector inputOI) { Map uninspMap = inputOI.getMap(mapObj); for (Object uninspKey : uninspMap.keySet()) { Object stdKey = ObjectInspectorUtils.copyToStandardJavaObject(uninspKey, inputOI.getMapKeyObjectInspector()); double stdVal = NumericUtil.getNumericValue((PrimitiveObjectInspector) inputOI.getMapValueObjectInspector(), uninspMap.get(uninspKey)); if (myagg.sumMap.containsKey(stdKey)) { double prevVal = myagg.sumMap.get(stdKey); myagg.sumMap.put(stdKey, prevVal + stdVal); } else { myagg.sumMap.put(stdKey, stdVal); } } }
if (!simpleLookup) { for (Object mapKey2 : map2.keySet()) { Object stdKey2 = ObjectInspectorUtils.copyToStandardJavaObject(mapKey2, map2Inspector.getMapKeyObjectInspector()); stdKeyMap.put(stdKey2, mapKey2); double mapVal1Dbl = NumericUtil.getNumericValue(value1Inspector, mapVal1Obj); Object stdKey1 = ObjectInspectorUtils.copyToStandardJavaObject(mapKey1, map1Inspector.getMapKeyObjectInspector());
if (!simpleLookup) { for (Object mapKey2 : map2.keySet()) { Object stdKey2 = ObjectInspectorUtils.copyToStandardJavaObject(mapKey2, map2Inspector.getMapKeyObjectInspector()); stdKeyMap.put(stdKey2, mapKey2); double mapVal1Dbl = NumericUtil.getNumericValue(value1Inspector, mapVal1Obj); Object stdKey1 = ObjectInspectorUtils.copyToStandardJavaObject(mapKey1, map1Inspector.getMapKeyObjectInspector());
public Object evaluateMap(Object uninspMapObj) { Object retMap = retMapInspector.create(); Map map = mapInspector.getMap(uninspMapObj); double tot = 0.0; for (Object mapKey : map.keySet()) { Object mapValObj = map.get(mapKey); double mapValDbl = NumericUtil.getNumericValue(valueInspector, mapValObj); tot += mapValDbl; } for (Object mapKey : map.keySet()) { Object mapValObj = map.get(mapKey); double mapValDbl = NumericUtil.getNumericValue(valueInspector, mapValObj); double newVal = mapValDbl / tot; Object stdKey = ObjectInspectorUtils.copyToStandardJavaObject(mapKey, mapInspector.getMapKeyObjectInspector()); Object stdVal = NumericUtil.castToPrimitiveNumeric(newVal, ((PrimitiveObjectInspector) retMapInspector.getMapValueObjectInspector()).getPrimitiveCategory()); retMapInspector.put(retMap, stdKey, stdVal); } return retMap; }
public Object evaluateMap(Object uninspMapObj, double scalar) { Object retMap = retMapInspector.create(); Map map = mapInspector.getMap(uninspMapObj); for (Object mapKey : map.keySet()) { Object mapValObj = map.get(mapKey); double mapValDbl = NumericUtil.getNumericValue(valueInspector, mapValObj); double newVal = mapValDbl * scalar; Object stdKey = ObjectInspectorUtils.copyToStandardJavaObject(mapKey, mapInspector.getMapKeyObjectInspector()); Object stdVal = NumericUtil.castToPrimitiveNumeric(newVal, ((PrimitiveObjectInspector) retMapInspector.getMapValueObjectInspector()).getPrimitiveCategory()); retMapInspector.put(retMap, stdKey, stdVal); } return retMap; }
Map stdKeyMap = new HashMap(); for (Object mapKey2 : map2.keySet()) { Object stdKey2 = ObjectInspectorUtils.copyToStandardJavaObject(mapKey2, map2Inspector.getMapKeyObjectInspector()); stdKeyMap.put(stdKey2, mapKey2); double mapVal1Dbl = NumericUtil.getNumericValue(value1Inspector, mapVal1Obj); Object stdKey1 = ObjectInspectorUtils.copyToStandardJavaObject(mapKey1, map1Inspector.getMapKeyObjectInspector());