@Override public String getName() { return funcDesc.getFunctionName(); }
@Override public String getName() { return funcDesc.getFunctionName(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for(int i=0; i < argEvals.length; i++) { sb.append(argEvals[i]); if(i+1 < argEvals.length) sb.append(","); } return funcDesc.getFunctionName() + "(" + (isDistinct() ? " distinct " : "") + sb+")"; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for(int i=0; i < argEvals.length; i++) { sb.append(argEvals[i]); if(i+1 < argEvals.length) sb.append(","); } return funcDesc.getFunctionName() + "(" + (isDistinct() ? " distinct " : "") + sb+")"; }
public String toString() { StringBuilder sb = new StringBuilder(); if (argEvals != null) { for(int i=0; i < argEvals.length; i++) { sb.append(argEvals[i]); if(i+1 < argEvals.length) sb.append(","); } } sb.append(funcDesc.getFunctionName()).append("(").append(isDistinct() ? " distinct" : "").append(sb) .append(")"); if (hasSortSpecs()) { sb.append("ORDER BY ").append(StringUtils.join(sortSpecs)); } return sb.toString(); } }
public String toString() { StringBuilder sb = new StringBuilder(); if (argEvals != null) { for(int i=0; i < argEvals.length; i++) { sb.append(argEvals[i]); if(i+1 < argEvals.length) sb.append(","); } } sb.append(funcDesc.getFunctionName()).append("(").append(isDistinct() ? " distinct" : "").append(sb) .append(")"); if (hasSortSpecs()) { sb.append("ORDER BY ").append(StringUtils.join(sortSpecs)); } return sb.toString(); } }
@Override public EvalNode visitFuncCall(EvalCodeGenContext context, FunctionEval function, Stack<EvalNode> stack) { super.visitFuncCall(context, function, stack); if (!context.symbols.containsKey(function)) { String fieldName = function.getFuncDesc().getFunctionName() + "_" + context.seqId++; context.symbols.put(function, fieldName); context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName, "L" + TajoGeneratorAdapter.getInternalName(function.getFuncDesc().getLegacyFuncClass()) + ";", null, null); } return function; } }
@Override public EvalNode visitFuncCall(EvalCodeGenContext context, FunctionEval function, Stack<EvalNode> stack) { super.visitFuncCall(context, function, stack); if (!context.symbols.containsKey(function)) { String fieldName = function.getFuncDesc().getFunctionName() + "_" + context.seqId++; context.symbols.put(function, fieldName); context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName, "L" + TajoGeneratorAdapter.getInternalName(function.getFuncDesc().getLegacyFuncClass()) + ";", null, null); } return function; } }
@Override public EvalNode visitFuncCall(Object context, FunctionEval evalNode, Stack<EvalNode> stack) { boolean constantOfAllDescendents = true; if ("sleep".equals(evalNode.funcDesc.getFunctionName())) { constantOfAllDescendents = false; } else { if (evalNode.getArgs() != null) { for (EvalNode arg : evalNode.getArgs()) { arg = visit(context, arg, stack); constantOfAllDescendents &= (arg.getType() == EvalType.CONST); } } } if (constantOfAllDescendents && evalNode.getType() == EvalType.FUNCTION) { return new ConstEval(evalNode.bind(null, null).eval(null)); } else { return evalNode; } } }
@Override public EvalNode visitFuncCall(Object context, FunctionEval evalNode, Stack<EvalNode> stack) { boolean constantOfAllDescendents = true; if ("sleep".equals(evalNode.funcDesc.getFunctionName())) { constantOfAllDescendents = false; } else { if (evalNode.getArgs() != null) { for (EvalNode arg : evalNode.getArgs()) { arg = visit(context, arg, stack); constantOfAllDescendents &= (arg.getType() == EvalType.CONST); } } } if (constantOfAllDescendents && evalNode.getType() == EvalType.FUNCTION) { return new ConstEval(evalNode.bind(null, null).eval(null)); } else { return evalNode; } } }
@Override public FunctionListResponse getFunctionList(RpcController controller, SessionedStringProto request) throws ServiceException { try { context.getSessionManager().touch(request.getSessionId().getId()); String functionName = request.getValue(); Collection<FunctionDesc> functions = catalog.getFunctions(); List<CatalogProtos.FunctionDescProto> functionProtos = new ArrayList<CatalogProtos.FunctionDescProto>(); for (FunctionDesc eachFunction: functions) { if (functionName == null || functionName.isEmpty()) { functionProtos.add(eachFunction.getProto()); } else { if(functionName.equals(eachFunction.getFunctionName())) { functionProtos.add(eachFunction.getProto()); } } } return FunctionListResponse.newBuilder() .setState(OK) .addAllFunction(functionProtos) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return FunctionListResponse.newBuilder(). setState(returnError(t)) .build(); } }
@Override public FunctionListResponse getFunctionList(RpcController controller, SessionedStringProto request) throws ServiceException { try { context.getSessionManager().touch(request.getSessionId().getId()); String functionName = request.getValue(); Collection<FunctionDesc> functions = catalog.getFunctions(); List<CatalogProtos.FunctionDescProto> functionProtos = new ArrayList<>(); for (FunctionDesc eachFunction: functions) { if (functionName == null || functionName.isEmpty()) { functionProtos.add(eachFunction.getProto()); } else { if(functionName.equals(eachFunction.getFunctionName())) { functionProtos.add(eachFunction.getProto()); } } } return FunctionListResponse.newBuilder() .setState(OK) .addAllFunction(functionProtos) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return FunctionListResponse.newBuilder(). setState(returnError(t)) .build(); } }
@Test public final void testGetFunctions() throws IOException, TajoException { Collection<FunctionDesc> catalogFunctions = cluster.getMaster().getCatalog().getFunctions(); String functionName = "sum"; int numFunctions = 0; for(FunctionDesc eachFunction: catalogFunctions) { if(functionName.equals(eachFunction.getFunctionName())) { numFunctions++; } } List<CatalogProtos.FunctionDescProto> functions = client.getFunctions(functionName); assertEquals(numFunctions, functions.size()); functions = client.getFunctions("notmatched"); assertEquals(0, functions.size()); functions = client.getFunctions(null); assertEquals(catalogFunctions.size(), functions.size()); }
@Test public void testAnalyzeUDFclass() { Set<Class<? extends UDF>> funcSet = new HashSet<>(); funcSet.add(HiveUDFtest.class); List<FunctionDesc> funcList = new LinkedList<>(); HiveFunctionLoader.buildFunctionsFromUDF(funcSet, funcList, null); assertEquals(funcList.size(), 1); FunctionDesc desc = funcList.get(0); assertEquals("multiplestr", desc.getFunctionName()); assertEquals(false, desc.isDeterministic()); assertEquals(TajoDataTypes.Type.TEXT, desc.getReturnType().getType()); assertEquals(TajoDataTypes.Type.TEXT, desc.getParamTypes()[0].getType()); assertEquals(TajoDataTypes.Type.INT4, desc.getParamTypes()[1].getType()); } }
boolean constantOfAllDescendents = true; if (NON_CONSTANT_FUNC_NAMES.contains(evalNode.getFuncDesc().getFunctionName())) { constantOfAllDescendents = false; } else {
boolean constantOfAllDescendents = true; if (NON_CONSTANT_FUNC_NAMES.contains(evalNode.getFuncDesc().getFunctionName())) { constantOfAllDescendents = false; } else {