public static List<TypeSignature> applyBoundVariables(List<TypeSignature> typeSignatures, BoundVariables boundVariables) { ImmutableList.Builder<TypeSignature> builder = ImmutableList.builder(); for (TypeSignature typeSignature : typeSignatures) { builder.add(applyBoundVariables(typeSignature, boundVariables)); } return builder.build(); }
public static List<TypeSignature> applyBoundVariables(List<TypeSignature> typeSignatures, BoundVariables boundVariables) { ImmutableList.Builder<TypeSignature> builder = ImmutableList.builder(); for (TypeSignature typeSignature : typeSignatures) { builder.add(applyBoundVariables(typeSignature, boundVariables)); } return builder.build(); }
public Optional<Signature> bind(List<? extends TypeSignatureProvider> actualArgumentTypes) { Optional<BoundVariables> boundVariables = bindVariables(actualArgumentTypes); if (!boundVariables.isPresent()) { return Optional.empty(); } return Optional.of(applyBoundVariables(declaredSignature, boundVariables.get(), actualArgumentTypes.size())); }
public Optional<Signature> bind(List<? extends TypeSignatureProvider> actualArgumentTypes, Type actualReturnType) { Optional<BoundVariables> boundVariables = bindVariables(actualArgumentTypes, actualReturnType); if (!boundVariables.isPresent()) { return Optional.empty(); } return Optional.of(applyBoundVariables(declaredSignature, boundVariables.get(), actualArgumentTypes.size())); }
@Override public Type resolve(BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { return typeManager.getType(applyBoundVariables(signature, boundVariables)); }
public Optional<Signature> bind(List<? extends TypeSignatureProvider> actualArgumentTypes, Type actualReturnType) { Optional<BoundVariables> boundVariables = bindVariables(actualArgumentTypes, actualReturnType); if (!boundVariables.isPresent()) { return Optional.empty(); } return Optional.of(applyBoundVariables(declaredSignature, boundVariables.get(), actualArgumentTypes.size())); }
public Optional<Signature> bind(List<? extends TypeSignatureProvider> actualArgumentTypes) { Optional<BoundVariables> boundVariables = bindVariables(actualArgumentTypes); if (!boundVariables.isPresent()) { return Optional.empty(); } return Optional.of(applyBoundVariables(declaredSignature, boundVariables.get(), actualArgumentTypes.size())); }
@Override public Type resolve(BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { return typeManager.getType(applyBoundVariables(signature, boundVariables)); }
public static TypeSignature applyBoundVariables(TypeSignature typeSignature, BoundVariables boundVariables) { String baseType = typeSignature.getBase(); if (boundVariables.containsTypeVariable(baseType)) { checkState(typeSignature.getParameters().isEmpty(), "Type parameters cannot have parameters"); return boundVariables.getTypeVariable(baseType).getTypeSignature(); } List<TypeSignatureParameter> parameters = typeSignature.getParameters().stream() .map(typeSignatureParameter -> applyBoundVariables(typeSignatureParameter, boundVariables)) .collect(toList()); return new TypeSignature(baseType, parameters); }
public static TypeSignature applyBoundVariables(TypeSignature typeSignature, BoundVariables boundVariables) { String baseType = typeSignature.getBase(); if (boundVariables.containsTypeVariable(baseType)) { checkState(typeSignature.getParameters().isEmpty(), "Type parameters cannot have parameters"); return boundVariables.getTypeVariable(baseType).getTypeSignature(); } List<TypeSignatureParameter> parameters = typeSignature.getParameters().stream() .map(typeSignatureParameter -> applyBoundVariables(typeSignatureParameter, boundVariables)) .collect(toList()); return new TypeSignature(baseType, parameters); }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type inputType = typeManager.getType(getOnlyElement(applyBoundVariables(getSignature().getArgumentTypes(), boundVariables))); Type outputType = typeManager.getType(applyBoundVariables(getSignature().getReturnType(), boundVariables)); return generateAggregation(inputType, outputType); }
private static void assertBindVariablesFails(String typeSignature, BoundVariables boundVariables, String reason) { try { SignatureBinder.applyBoundVariables(parseTypeSignature(typeSignature, ImmutableSet.of("p", "s")), boundVariables); fail(reason); } catch (RuntimeException e) { // Expected } }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type type = typeManager.getType(getOnlyElement(applyBoundVariables(getSignature().getArgumentTypes(), boundVariables))); return generateAggregation(type); }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type type = typeManager.getType(getOnlyElement(applyBoundVariables(getSignature().getArgumentTypes(), boundVariables))); return generateAggregation(type); }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type inputType = typeManager.getType(getOnlyElement(applyBoundVariables(getSignature().getArgumentTypes(), boundVariables))); Type outputType = typeManager.getType(applyBoundVariables(getSignature().getReturnType(), boundVariables)); return generateAggregation(inputType, outputType); }
private static void assertBindVariablesFails(String typeSignature, BoundVariables boundVariables, String reason) { try { SignatureBinder.applyBoundVariables(parseTypeSignature(typeSignature, ImmutableSet.of("p", "s")), boundVariables); fail(reason); } catch (RuntimeException e) { // Expected } }
@Override public MethodHandle resolve(BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { Signature signature = applyBoundVariables(this.signature, boundVariables, this.signature.getArgumentTypes().size()); if (invocationConvention.isPresent()) { return functionRegistry.getFunctionInvokerProvider().createFunctionInvoker(signature, invocationConvention).methodHandle(); } else { return functionRegistry.getScalarFunctionImplementation(signature).getMethodHandle(); } }
@Override public MethodHandle resolve(BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { Signature signature = applyBoundVariables(this.signature, boundVariables, this.signature.getArgumentTypes().size()); if (invocationConvention.isPresent()) { return functionRegistry.getFunctionInvokerProvider().createFunctionInvoker(signature, invocationConvention).methodHandle(); } else { return functionRegistry.getScalarFunctionImplementation(signature).getMethodHandle(); } }
private static void assertThat(String typeSignature, BoundVariables boundVariables, String expectedTypeSignature) { assertEquals( SignatureBinder.applyBoundVariables(parseTypeSignature(typeSignature, ImmutableSet.of("p", "s")), boundVariables).toString(), expectedTypeSignature); }
private static void assertThat(String typeSignature, BoundVariables boundVariables, String expectedTypeSignature) { assertEquals( SignatureBinder.applyBoundVariables(parseTypeSignature(typeSignature, ImmutableSet.of("p", "s")), boundVariables).toString(), expectedTypeSignature); }