private void validateAndSetupPatternStr(MatchPath evaluator, List<PTFExpressionDef> args) throws SemanticException { PTFExpressionDef symboPatternArg = args.get(0); ObjectInspector symbolPatternArgOI = symboPatternArg.getOI(); if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolPatternArgOI) || (symbolPatternArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector)symbolPatternArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING ) { throwErrorWithSignature("Currently the symbol Pattern must be a Constant String."); } evaluator.patternStr = ((ConstantObjectInspector)symbolPatternArgOI). getWritableConstantValue().toString(); }
private void validateAndSetupResultExprStr(MatchPath evaluator, List<PTFExpressionDef> args, int argsNum) throws SemanticException { PTFExpressionDef resultExprArg = args.get(argsNum - 1); ObjectInspector resultExprArgOI = resultExprArg.getOI(); if ( !ObjectInspectorUtils.isConstantObjectInspector(resultExprArgOI) || (resultExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector)resultExprArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING ) { throwErrorWithSignature("Currently the result Expr parameter must be a Constant String."); } evaluator.resultExprStr = ((ConstantObjectInspector)resultExprArgOI). getWritableConstantValue().toString(); }
private void validateAndSetupPatternStr(MatchPath evaluator, List<PTFExpressionDef> args) throws SemanticException { PTFExpressionDef symboPatternArg = args.get(0); ObjectInspector symbolPatternArgOI = symboPatternArg.getOI(); if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolPatternArgOI) || (symbolPatternArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector)symbolPatternArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING ) { throwErrorWithSignature("Currently the symbol Pattern must be a Constant String."); } evaluator.patternStr = ((ConstantObjectInspector)symbolPatternArgOI). getWritableConstantValue().toString(); }
private void validateAndSetupResultExprStr(MatchPath evaluator, List<PTFExpressionDef> args, int argsNum) throws SemanticException { PTFExpressionDef resultExprArg = args.get(argsNum - 1); ObjectInspector resultExprArgOI = resultExprArg.getOI(); if ( !ObjectInspectorUtils.isConstantObjectInspector(resultExprArgOI) || (resultExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector)resultExprArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING ) { throwErrorWithSignature("Currently the result Expr parameter must be a Constant String."); } evaluator.resultExprStr = ((ConstantObjectInspector)resultExprArgOI). getWritableConstantValue().toString(); }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 2) { throw new UDFArgumentLengthException( "IN_FILE() accepts exactly 2 arguments."); } strObjectInspector = arguments[0]; fileObjectInspector = arguments[1]; if (!isTypeCompatible(strObjectInspector)) { throw new UDFArgumentTypeException(0, "The first " + "argument of function IN_FILE must be a string, " + "char or varchar but " + strObjectInspector.toString() + " was given."); } if (((PrimitiveObjectInspector) fileObjectInspector).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING || !ObjectInspectorUtils.isConstantObjectInspector(fileObjectInspector)) { throw new UDFArgumentTypeException(1, "The second " + "argument of IN_FILE() must be a constant string but " + fileObjectInspector.toString() + " was given."); } return PrimitiveObjectInspectorFactory.javaBooleanObjectInspector; }
@Override public ObjectInspector initialize(ObjectInspector rowInspector) throws HiveException { deferredChildren = new GenericUDF.DeferredObject[children.length]; List<GenericUDF.DeferredObject> childrenNeedingPrepare = new ArrayList<GenericUDF.DeferredObject>(children.length); for (int i = 0; i < deferredChildren.length; i++) { DeferredExprObject deferredExprObject = new DeferredExprObject(children[i], isEager); deferredChildren[i] = deferredExprObject; if (deferredExprObject.needsPrepare()) { childrenNeedingPrepare.add(deferredExprObject); } } this.childrenNeedingPrepare = childrenNeedingPrepare.toArray(new GenericUDF.DeferredObject[childrenNeedingPrepare.size()]); // Initialize all children first ObjectInspector[] childrenOIs = new ObjectInspector[children.length]; for (int i = 0; i < children.length; i++) { childrenOIs[i] = children[i].initialize(rowInspector); } MapredContext context = MapredContext.get(); if (context != null) { context.setup(genericUDF); } outputOI = genericUDF.initializeAndFoldConstants(childrenOIs); isConstant = ObjectInspectorUtils.isConstantObjectInspector(outputOI) && isConsistentWithinQuery(); return outputOI; }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 2) { throw new UDFArgumentLengthException( "IN_FILE() accepts exactly 2 arguments."); } strObjectInspector = arguments[0]; fileObjectInspector = arguments[1]; if (!isTypeCompatible(strObjectInspector)) { throw new UDFArgumentTypeException(0, "The first " + "argument of function IN_FILE must be a string, " + "char or varchar but " + strObjectInspector.toString() + " was given."); } if (((PrimitiveObjectInspector) fileObjectInspector).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING || !ObjectInspectorUtils.isConstantObjectInspector(fileObjectInspector)) { throw new UDFArgumentTypeException(1, "The second " + "argument of IN_FILE() must be a constant string but " + fileObjectInspector.toString() + " was given."); } return PrimitiveObjectInspectorFactory.javaBooleanObjectInspector; }
@Override public ObjectInspector initialize(ObjectInspector rowInspector) throws HiveException { deferredChildren = new GenericUDF.DeferredObject[children.length]; List<GenericUDF.DeferredObject> childrenNeedingPrepare = new ArrayList<GenericUDF.DeferredObject>(children.length); for (int i = 0; i < deferredChildren.length; i++) { DeferredExprObject deferredExprObject = new DeferredExprObject(children[i], isEager); deferredChildren[i] = deferredExprObject; if (deferredExprObject.needsPrepare()) { childrenNeedingPrepare.add(deferredExprObject); } } this.childrenNeedingPrepare = childrenNeedingPrepare.toArray(new GenericUDF.DeferredObject[childrenNeedingPrepare.size()]); // Initialize all children first ObjectInspector[] childrenOIs = new ObjectInspector[children.length]; for (int i = 0; i < children.length; i++) { childrenOIs[i] = children[i].initialize(rowInspector); } MapredContext context = MapredContext.get(); if (context != null) { context.setup(genericUDF); } outputOI = genericUDF.initializeAndFoldConstants(childrenOIs); isConstant = ObjectInspectorUtils.isConstantObjectInspector(outputOI) && isDeterministic(); return outputOI; }
ObjectInspector symbolNameArgOI = symbolNameArg.getOI(); if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolNameArgOI) || (symbolNameArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector)symbolNameArgOI).getPrimitiveCategory() !=
if (!ObjectInspectorUtils.isConstantObjectInspector(arguments[ii])) { allConstant = false; break; !ObjectInspectorUtils.isConstantObjectInspector(oi) && FunctionRegistry.isConsistentWithinQuery(this) && ObjectInspectorUtils.supportsConstantObjectInspector(oi)) {
ObjectInspector symbolNameArgOI = symbolNameArg.getOI(); if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolNameArgOI) || (symbolNameArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector)symbolNameArgOI).getPrimitiveCategory() !=
if (!ObjectInspectorUtils.isConstantObjectInspector(arguments[ii])) { allConstant = false; break; !ObjectInspectorUtils.isConstantObjectInspector(oi) && FunctionRegistry.isDeterministic(this) && !FunctionRegistry.isStateful(this) &&
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (!(arguments.length >= 1 && arguments.length <= 3)) { throw new UDFArgumentTypeException(arguments.length - 1, "Incorrect invocation of " + _getFnName() + ": _FUNC_(expr, amt, default)"); } amt = 1; if (arguments.length > 1) { ObjectInspector amtOI = arguments[1]; if (!ObjectInspectorUtils.isConstantObjectInspector(amtOI) || (amtOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector) amtOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.INT) { throw new UDFArgumentTypeException(1, _getFnName() + " amount must be a integer value " + amtOI.getTypeName() + " was passed as parameter 1."); } Object o = ((ConstantObjectInspector) amtOI).getWritableConstantValue(); amt = ((IntWritable) o).get(); if (amt < 0) { throw new UDFArgumentTypeException(1, " amount can not be nagative. Specified: " + amt); } } if (arguments.length == 3) { defaultValueConverter = ObjectInspectorConverters.getConverter(arguments[2], arguments[0]); } firstArgOI = arguments[0]; return ObjectInspectorUtils.getStandardObjectInspector(firstArgOI, ObjectInspectorCopyOption.WRITABLE); }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { checkArgsSize(arguments, 2, 2); checkArgPrimitive(arguments, 0); checkArgPrimitive(arguments, 1); if (!ObjectInspectorUtils.isConstantObjectInspector(arguments[1])) { throw new UDFArgumentTypeException(1, getFuncName() + " argument 2 may only be a constant"); } inputConverter = new TextConverter((PrimitiveObjectInspector) arguments[0]); String typeStr = getConstantStringValue(arguments, 1); try { TypeInfo t = TypeInfoUtils.getTypeInfoFromTypeString(typeStr); jsonReader = new HiveJsonStructReader(t); jsonReader.setWritablesUsage(true); } catch (Exception e) { throw new UDFArgumentException(getFuncName() + ": Error parsing typestring: " + e.getMessage()); } return jsonReader.getObjectInspector(); }
ObjectInspector amtOI = paramOIs[1]; if (!ObjectInspectorUtils.isConstantObjectInspector(amtOI) || (amtOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector) amtOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.INT) {
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (!(arguments.length >= 1 && arguments.length <= 3)) { throw new UDFArgumentTypeException(arguments.length - 1, "Incorrect invocation of " + _getFnName() + ": _FUNC_(expr, amt, default)"); } amt = 1; if (arguments.length > 1) { ObjectInspector amtOI = arguments[1]; if (!ObjectInspectorUtils.isConstantObjectInspector(amtOI) || (amtOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector) amtOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.INT) { throw new UDFArgumentTypeException(1, _getFnName() + " amount must be a integer value " + amtOI.getTypeName() + " was passed as parameter 1."); } Object o = ((ConstantObjectInspector) amtOI).getWritableConstantValue(); amt = ((IntWritable) o).get(); if (amt < 0) { throw new UDFArgumentTypeException(1, " amount can not be nagative. Specified: " + amt); } } if (arguments.length == 3) { defaultValueConverter = ObjectInspectorConverters.getConverter(arguments[2], arguments[0]); } firstArgOI = arguments[0]; return ObjectInspectorUtils.getStandardObjectInspector(firstArgOI, ObjectInspectorCopyOption.WRITABLE); }
ObjectInspector amtOI = paramOIs[1]; if (!ObjectInspectorUtils.isConstantObjectInspector(amtOI) || (amtOI.getCategory() != ObjectInspector.Category.PRIMITIVE) || ((PrimitiveObjectInspector) amtOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.INT) {
if (!ObjectInspectorUtils.isConstantObjectInspector(parameters[1])) { throw new UDFArgumentTypeException(1, "The second argument must be a constant, but " + parameters[1].getTypeName() + if (!ObjectInspectorUtils.isConstantObjectInspector(parameters[2])) { throw new UDFArgumentTypeException(2, "The third argument must be a constant, but " + parameters[2].getTypeName() +
if (!ObjectInspectorUtils.isConstantObjectInspector(parameters[1])) { throw new UDFArgumentTypeException(1, "The second argument must be a constant, but " + parameters[1].getTypeName() + if (!ObjectInspectorUtils.isConstantObjectInspector(parameters[2])) { throw new UDFArgumentTypeException(2, "The third argument must be a constant, but " + parameters[2].getTypeName() +
public static Map<String, String> getConfigFromConstMapInspector(ObjectInspector objInspector) throws UDFArgumentException { if (!(ObjectInspectorUtils.isConstantObjectInspector(objInspector)) || !(objInspector instanceof StandardConstantMapObjectInspector)) { throw new UDFArgumentException("HBase parameters must be a constant map"); } StandardConstantMapObjectInspector constMapInsp = (StandardConstantMapObjectInspector) objInspector; Map<?, ?> uninspMap = constMapInsp.getWritableConstantValue(); System.out.println(" Uninsp Map = " + uninspMap + " size is " + uninspMap.size()); Map<String, String> configMap = new HashMap<String, String>(); for (Object uninspKey : uninspMap.keySet()) { Object uninspVal = uninspMap.get(uninspKey); String key = ((StringObjectInspector) constMapInsp.getMapKeyObjectInspector()).getPrimitiveJavaObject(uninspKey); String val = ((StringObjectInspector) constMapInsp.getMapValueObjectInspector()).getPrimitiveJavaObject(uninspVal); LOG.info(" Key " + key + " VAL = " + configMap.get(key)); System.out.println(" Key " + key + " VAL = " + configMap.get(key)); configMap.put(key, val); } return configMap; }