public OperatorImplementationDependency(OperatorType operator, TypeSignature returnType, List<TypeSignature> argumentTypes, Optional<InvocationConvention> invocationConvention) { super(internalOperator(operator, returnType, argumentTypes), invocationConvention); this.operator = requireNonNull(operator, "operator is null"); }
public OperatorImplementationDependency(OperatorType operator, TypeSignature returnType, List<TypeSignature> argumentTypes, Optional<InvocationConvention> invocationConvention) { super(internalOperator(operator, returnType, argumentTypes), invocationConvention); this.operator = requireNonNull(operator, "operator is null"); }
public boolean canResolveOperator(OperatorType operatorType, Type returnType, List<? extends Type> argumentTypes) { Signature signature = internalOperator(operatorType, returnType, argumentTypes); return isRegistered(signature); }
public boolean canResolveOperator(OperatorType operatorType, Type returnType, List<? extends Type> argumentTypes) { Signature signature = internalOperator(operatorType, returnType, argumentTypes); return isRegistered(signature); }
private Optional<Signature> getSaturatedFloorCastOperator(Type fromType, Type toType) { if (metadata.getFunctionRegistry().canResolveOperator(SATURATED_FLOOR_CAST, toType, ImmutableList.of(fromType))) { return Optional.of(internalOperator(SATURATED_FLOOR_CAST, toType, ImmutableList.of(fromType))); } return Optional.empty(); }
private Optional<Signature> getSaturatedFloorCastOperator(Type fromType, Type toType) { if (metadata.getFunctionRegistry().canResolveOperator(SATURATED_FLOOR_CAST, toType, ImmutableList.of(fromType))) { return Optional.of(internalOperator(SATURATED_FLOOR_CAST, toType, ImmutableList.of(fromType))); } return Optional.empty(); }
public static Signature arithmeticNegationSignature(Type returnType, Type valueType) { return internalOperator("NEGATION", returnType.getTypeSignature(), valueType.getTypeSignature()); }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type type = boundVariables.getTypeVariable("E"); MethodHandle compareMethodHandle = functionRegistry.getScalarFunctionImplementation(internalOperator(operatorType, BOOLEAN, ImmutableList.of(type, type))).getMethodHandle(); return generateAggregation(type, compareMethodHandle); }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type type = boundVariables.getTypeVariable("E"); MethodHandle compareMethodHandle = functionRegistry.getScalarFunctionImplementation(internalOperator(operatorType, BOOLEAN, ImmutableList.of(type, type))).getMethodHandle(); return generateAggregation(type, compareMethodHandle); }
public static Signature betweenSignature(Type valueType, Type minType, Type maxType) { return internalOperator("BETWEEN", parseTypeSignature(StandardTypes.BOOLEAN), valueType.getTypeSignature(), minType.getTypeSignature(), maxType.getTypeSignature()); }
public static Signature arithmeticExpressionSignature(ArithmeticBinaryExpression.Operator operator, Type returnType, Type leftType, Type rightType) { return internalOperator(operator.name(), returnType.getTypeSignature(), leftType.getTypeSignature(), rightType.getTypeSignature()); }
public static Signature subscriptSignature(Type returnType, Type leftType, Type rightType) { return internalOperator(SUBSCRIPT.name(), returnType.getTypeSignature(), leftType.getTypeSignature(), rightType.getTypeSignature()); }
public static Signature comparisonExpressionSignature(ComparisonExpression.Operator operator, Type leftType, Type rightType) { for (OperatorType operatorType : OperatorType.values()) { if (operatorType.name().equals(operator.name())) { return internalOperator(operator.name(), parseTypeSignature(StandardTypes.BOOLEAN), leftType.getTypeSignature(), rightType.getTypeSignature()); } } return internalScalarFunction(operator.name(), parseTypeSignature(StandardTypes.BOOLEAN), leftType.getTypeSignature(), rightType.getTypeSignature()); }
public static Signature comparisonExpressionSignature(ComparisonExpression.Operator operator, Type leftType, Type rightType) { for (OperatorType operatorType : OperatorType.values()) { if (operatorType.name().equals(operator.name())) { return internalOperator(operator.name(), parseTypeSignature(StandardTypes.BOOLEAN), leftType.getTypeSignature(), rightType.getTypeSignature()); } } return internalScalarFunction(operator.name(), parseTypeSignature(StandardTypes.BOOLEAN), leftType.getTypeSignature(), rightType.getTypeSignature()); }
@Test(timeOut = 10_000) public void testPossibleExponentialOptimizationTime() { RowExpression expression = constant(1L, BIGINT); for (int i = 0; i < 100; i++) { Signature signature = internalOperator(OperatorType.ADD.name(), parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT)); expression = new CallExpression(signature, BIGINT, ImmutableList.of(expression, constant(1L, BIGINT))); } optimizer.optimize(expression); }
@Test(timeOut = 10_000) public void testPossibleExponentialOptimizationTime() { RowExpression expression = constant(1L, BIGINT); for (int i = 0; i < 100; i++) { Signature signature = internalOperator(OperatorType.ADD.name(), parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT)); expression = new CallExpression(signature, BIGINT, ImmutableList.of(expression, constant(1L, BIGINT))); } optimizer.optimize(expression); }
private static RowExpression createComparison(int leftField, int rightField) { return call( internalOperator(OperatorType.EQUAL, BOOLEAN.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()), BOOLEAN, field(leftField, BIGINT), field(rightField, BIGINT)); }
private static RowExpression createComparison(int leftField, int rightField) { return call( internalOperator(OperatorType.EQUAL, BOOLEAN.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()), BOOLEAN, field(leftField, BIGINT), field(rightField, BIGINT)); }
@Test public void testIfConstantOptimization() { assertEquals(optimizer.optimize(ifExpression(constant(true, BOOLEAN), 1L, 2L)), constant(1L, BIGINT)); assertEquals(optimizer.optimize(ifExpression(constant(false, BOOLEAN), 1L, 2L)), constant(2L, BIGINT)); assertEquals(optimizer.optimize(ifExpression(constant(null, BOOLEAN), 1L, 2L)), constant(2L, BIGINT)); Signature bigintEquals = internalOperator(OperatorType.EQUAL.name(), BOOLEAN.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()); RowExpression condition = new CallExpression(bigintEquals, BOOLEAN, ImmutableList.of(constant(3L, BIGINT), constant(3L, BIGINT))); assertEquals(optimizer.optimize(ifExpression(condition, 1L, 2L)), constant(1L, BIGINT)); }
@Test public void testIfConstantOptimization() { assertEquals(optimizer.optimize(ifExpression(constant(true, BOOLEAN), 1L, 2L)), constant(1L, BIGINT)); assertEquals(optimizer.optimize(ifExpression(constant(false, BOOLEAN), 1L, 2L)), constant(2L, BIGINT)); assertEquals(optimizer.optimize(ifExpression(constant(null, BOOLEAN), 1L, 2L)), constant(2L, BIGINT)); Signature bigintEquals = internalOperator(OperatorType.EQUAL.name(), BOOLEAN.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()); RowExpression condition = new CallExpression(bigintEquals, BOOLEAN, ImmutableList.of(constant(3L, BIGINT), constant(3L, BIGINT))); assertEquals(optimizer.optimize(ifExpression(condition, 1L, 2L)), constant(1L, BIGINT)); }