private static String likeString(FunctionCall call) { return ((QuotedString) call.args.get(1)).value; }
private static Character escapeString(FunctionCall call) { if (call.args.size() > 2) { return ((QuotedString) call.args.get(2)).value.charAt(0); } return null; }
@Override public Void visitFunctionHolderExpression(FunctionHolderExpression holder, StringBuilder sb) throws RuntimeException { ImmutableList<LogicalExpression> args = holder.args; sb.append(holder.getName()); sb.append("("); for (int i = 0; i < args.size(); i++) { if (i != 0) { sb.append(", "); } args.get(i).accept(this, sb); } sb.append(") "); return null; }
@Override public Void visitFunctionCall(FunctionCall call, StringBuilder sb) throws RuntimeException { ImmutableList<LogicalExpression> args = call.args; sb.append(call.getName()); sb.append("("); for (int i = 0; i < args.size(); i++) { if (i != 0) { sb.append(", "); } args.get(i).accept(this, sb); } sb.append(") "); return null; }
@Override public Boolean visitFunctionCall(FunctionCall call, LogicalExpression valueArg) { Matcher matcher = convertFromPattern.matcher(call.getName()); if (matcher.find()) { // convert function call to ConvertExpression ConvertExpression convert = new ConvertExpression(ConvertExpression.CONVERT_FROM, matcher.group(1), call.args.get(0), call.getPosition()); return visitConvertExpression(convert, valueArg); } return false; }
private static CompareFunctionsProcessor processWithEvaluator(FunctionCall call, CompareFunctionsProcessor evaluator) { String functionName = call.getName(); LogicalExpression nameArg = call.args.get(0); LogicalExpression valueArg = call.args.size() >= 2 ? call.args.get(1) : null; if (valueArg != null) { if (VALUE_EXPRESSION_CLASSES.contains(nameArg.getClass())) { LogicalExpression swapArg = valueArg; valueArg = nameArg; nameArg = swapArg; evaluator.functionName = COMPARE_FUNCTIONS_TRANSPOSE_MAP.get(functionName); } evaluator.success = nameArg.accept(evaluator, valueArg); } return evaluator; }
public static KafkaNodeProcessor process(FunctionCall call) { String functionName = call.getName(); LogicalExpression nameArg = call.args.get(0); LogicalExpression valueArg = call.args.size() >= 2? call.args.get(1) : null; KafkaNodeProcessor evaluator = new KafkaNodeProcessor(functionName); if (VALUE_EXPRESSION_CLASSES.contains(nameArg.getClass())) { LogicalExpression swapArg = valueArg; valueArg = nameArg; nameArg = swapArg; evaluator.functionName = COMPARE_FUNCTIONS_TRANSPOSE_MAP.get(functionName); } evaluator.success = nameArg.accept(evaluator, valueArg); return evaluator; }
@Override public LogicalExpression visitFunctionHolderExpression(FunctionHolderExpression holder, Void value) throws RuntimeException { List<LogicalExpression> args = Lists.newArrayList(); for (int i = 0; i < holder.args.size(); ++i) { LogicalExpression newExpr = holder.args.get(i).accept(this, value); assert newExpr != null; args.add(newExpr); } //replace with a new function call, since its argument could be changed. return holder.copy(args); }
@Override public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { boolean allArgsAreConstant = true; for (int i = 0; i < holder.args.size(); i++) { boolean thisArgIsConstant = holder.args.get(i).accept(this, errors); if (!thisArgIsConstant) { allArgsAreConstant = false; if (holder.argConstantOnly(i)) { errors.addGeneralError( // holder.args.get(i).getPosition(), // String.format("Function %s expects constant input for argument number %d", holder.getName(), i)); } } } return allArgsAreConstant; }
protected static <T extends CompareFunctionsProcessor> T createFunctionsProcessorInstanceInternal(FunctionCall call, boolean nullComparatorSupported, T evaluator) { LogicalExpression nameArg = call.args.get(0); LogicalExpression valueArg = call.args.size() >= 2 ? call.args.get(1) : null; if (valueArg != null) { // binary function if (VALUE_EXPRESSION_CLASSES.contains(nameArg.getClass())) { LogicalExpression swapArg = valueArg; valueArg = nameArg; nameArg = swapArg; evaluator.setFunctionName(COMPARE_FUNCTIONS_TRANSPOSE_MAP.get(evaluator.getFunctionName())); } evaluator.setSuccess(nameArg.accept(evaluator, valueArg)); } else if (nullComparatorSupported && call.args.get(0) instanceof SchemaPath) { evaluator.setSuccess(true); evaluator.setPath((SchemaPath) nameArg); } return evaluator; }
@Override public Void visitFunctionCall(FunctionCall call, Void v) throws RuntimeException { final String functionName = call.getName(); final String fieldName = FieldPathHelper.schemaPath2FieldPath(getSchemaPathArg(call.args.get(0))).asPathString(); switch(functionName) { case "ojai_sizeof": { final String relOp = getStringArg(call.args.get(1)); final long size = getLongArg(call.args.get(2)); queryCond = MapRDBImpl.newCondition() .sizeOf(fieldName, STRING_TO_RELOP.get(relOp), size) case "ojai_nottypeof": { final int typeCode = getIntArg(call.args.get(1)); final Value.Type typeValue = Value.Type.valueOf(typeCode); queryCond = MapRDBImpl.newCondition(); case "ojai_notmatches": { final SchemaPath schemaPath = getSchemaPathArg(call.args.get(0)); final String regex = getStringArg(call.args.get(1)); if (functionName.equals("ojai_matches")) { queryCond = MapRDBImpl.newCondition() final SchemaPath schemaPath = getSchemaPathArg(call.args.get(0)); final String condString = getStringArg(call.args.get(1)); final byte[] condBytes = Base64.decodeBase64(condString); final ByteBuffer condBuffer = ByteBuffer.wrap(condBytes);
case "booleanAnd": case "booleanOr": HBaseScanSpec firstScanSpec = args.get(0).accept(this, null); for (int i = 1; i < args.size(); ++i) { HBaseScanSpec nextScanSpec = args.get(i).accept(this, null); if (firstScanSpec != null && nextScanSpec != null) { nodeScanSpec = mergeScanSpecs(functionName, firstScanSpec, nextScanSpec);
@Override public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, ErrorCollector errors) { if (holder.isAggregating()) { for (int i = 0; i < holder.args.size(); i++) { LogicalExpression e = holder.args.get(i); if(e.accept(this, errors)) { errors.addGeneralError(e.getPosition(), String.format("Aggregating function call %s includes nested aggregations at arguments number %d. " + "This isn't allowed.", holder.getName(), i)); } } return true; } else { for (LogicalExpression e : holder.args) { if (e.accept(this, errors)) { return true; } } return false; } }
case "booleanAnd": case "booleanOr": HBaseScanSpec firstScanSpec = args.get(0).accept(this, null); for (int i = 1; i < args.size(); ++i) { HBaseScanSpec nextScanSpec = args.get(i).accept(this, null); if (firstScanSpec != null && nextScanSpec != null) { nodeScanSpec = mergeScanSpecs(functionName, firstScanSpec, nextScanSpec);
for (int i=0; i<call.args.size(); i++) { try { argTypes[i] = call.args.get(i).getMajorType(); argOIs[i] = ObjectInspectorHelper.getDrillObjectInspector(argTypes[i].getMode(), argTypes[i].getMinorType(), varCharToStringReplacement);
@Override int copyIntoArray(Object[] dst, int offset) { // this loop is faster for RandomAccess instances, which ImmutableLists are int size = size(); for (int i = 0; i < size; i++) { dst[offset + i] = get(i); } return offset + size; }
@Override public int compare(T left, T right) { // Avoid using the Iterator to avoid generating garbage (issue 979). int size = comparators.size(); for (int i = 0; i < size; i++) { int result = comparators.get(i).compare(left, right); if (result != 0) { return result; } } return 0; }
@Override public void forEach(Consumer<? super E> consumer) { checkNotNull(consumer); int n = size(); for (int i = 0; i < n; i++) { consumer.accept(get(i)); } }