use of org.apache.phoenix.coprocessor.generated.PFunctionProtos.PFunctionArg in project phoenix by apache.
the class PFunction method createFromProto.
public static PFunction createFromProto(org.apache.phoenix.coprocessor.generated.PFunctionProtos.PFunction function) {
PName tenantId = null;
if (function.hasTenantId()) {
tenantId = PNameFactory.newName(function.getTenantId().toByteArray());
}
String functionName = function.getFunctionName();
long timeStamp = function.getTimeStamp();
String className = function.getClassname();
String jarPath = function.getJarPath();
String returnType = function.getReturnType();
List<FunctionArgument> args = new ArrayList<FunctionArgument>(function.getArgumentsCount());
for (PFunctionArg arg : function.getArgumentsList()) {
String argType = arg.getArgumentType();
boolean isArrayType = arg.hasIsArrayType() ? arg.getIsArrayType() : false;
PDataType dataType = isArrayType ? PDataType.fromTypeId(PDataType.sqlArrayType(SchemaUtil.normalizeIdentifier(SchemaUtil.normalizeIdentifier(argType)))) : PDataType.fromSqlTypeName(SchemaUtil.normalizeIdentifier(argType));
boolean isConstant = arg.hasIsConstant() ? arg.getIsConstant() : false;
String defaultValue = arg.hasDefaultValue() ? arg.getDefaultValue() : null;
String minValue = arg.hasMinValue() ? arg.getMinValue() : null;
String maxValue = arg.hasMaxValue() ? arg.getMaxValue() : null;
args.add(new FunctionArgument(argType, isArrayType, isConstant, defaultValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(defaultValue))).getValue()), minValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(minValue))).getValue()), maxValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(maxValue))).getValue())));
}
return new PFunction(tenantId, functionName, args, returnType, className, jarPath, timeStamp, false, function.hasIsReplace() ? true : false);
}
Aggregations