}
/*
* validate and setup patternStr
*/
ArgDef 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();
/*
* validate and setup SymbolInfo
*/
int symbolArgsSz = argsNum - 2;
if ( symbolArgsSz % 2 != 0)
{
throwErrorWithSignature("Symbol Name, Expression need to be specified in pairs: there are odd number of symbol args");
}
evaluator.symInfo = new SymbolsInfo(symbolArgsSz/2);
for(int i=1; i <= symbolArgsSz; i += 2)
{
ArgDef symbolNameArg = args.get(i);
ObjectInspector symbolNameArgOI = symbolNameArg.getOI();
if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolNameArgOI) ||
(symbolNameArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
((PrimitiveObjectInspector)symbolNameArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING )
{
throwErrorWithSignature(sprintf("Currently a Symbol Name(%s) must be a Constant String", symbolNameArg.getExpression().toStringTree()));
}
String symbolName = ((ConstantObjectInspector)symbolNameArgOI).getWritableConstantValue().toString();
ArgDef symolExprArg = args.get(i+1);
ObjectInspector symolExprArgOI = symolExprArg.getOI();
if ( (symolExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
((PrimitiveObjectInspector)symolExprArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.BOOLEAN )
{
throwErrorWithSignature(sprintf("Currently a Symbol Expression(%s) must be a boolean expression", symolExprArg.getExpression().toStringTree()));
}
evaluator.symInfo.add(symbolName, symolExprArg);
}
/*
* validate and setup resultExprStr
*/
ArgDef resultExprArg = args.get(argsNum - 1);
ObjectInspector resultExprArgOI = resultExprArg.getOI();
if ( !ObjectInspectorUtils.isConstantObjectInspector(resultExprArgOI) ||
(resultExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
((PrimitiveObjectInspector)resultExprArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING )
{