本文整理汇总了Java中io.crate.metadata.FunctionImplementation类的典型用法代码示例。如果您正苦于以下问题:Java FunctionImplementation类的具体用法?Java FunctionImplementation怎么用?Java FunctionImplementation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FunctionImplementation类属于io.crate.metadata包,在下文中一共展示了FunctionImplementation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitFunction
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public Input<?> visitFunction(Function function, C context) {
final FunctionImplementation functionImplementation = functions.get(function.info().ident());
if (functionImplementation != null && functionImplementation instanceof Scalar<?, ?>) {
List<Symbol> arguments = function.arguments();
Scalar<?, ?> scalarImpl = ((Scalar) functionImplementation).compile(arguments);
Input[] argumentInputs = new Input[arguments.size()];
int i = 0;
for (Symbol argument : function.arguments()) {
argumentInputs[i++] = process(argument, context);
}
return new FunctionExpression<>(scalarImpl, argumentInputs);
} else {
throw new IllegalArgumentException(
SymbolFormatter.format("Cannot find implementation for function %s", function));
}
}
示例2: visitAggregation
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public Input<?> visitAggregation(Aggregation symbol, Context context) {
FunctionImplementation impl = functions.get(symbol.functionIdent());
if (impl == null) {
throw new UnsupportedOperationException(
SymbolFormatter.format("Can't load aggregation impl for symbol %s", symbol));
}
AggregationContext aggregationContext = new AggregationContext((AggregationFunction) impl, symbol);
for (Symbol aggInput : symbol.inputs()) {
aggregationContext.addInput(process(aggInput, context));
}
context.aggregations.add(aggregationContext);
// can't generate an input from an aggregation.
// since they cannot/shouldn't be nested this should be okay.
return null;
}
示例3: printGenericFunction
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
private void printGenericFunction(Function function, SymbolPrinterContext context) {
FunctionFormatSpec functionFormatSpec = null;
OperatorFormatSpec operatorFormatSpec = null;
if (functions != null) {
FunctionImplementation<?> impl = functions.get(function.info().ident());
if (impl instanceof FunctionFormatSpec) {
functionFormatSpec = (FunctionFormatSpec)impl;
} else if (impl instanceof OperatorFormatSpec) {
operatorFormatSpec = (OperatorFormatSpec)impl;
}
} else if (function.info().ident().name().startsWith("op_")) {
operatorFormatSpec = SIMPLE_OPERATOR_FORMAT_SPEC;
}
if (operatorFormatSpec != null) {
printOperator(function, operatorFormatSpec, context);
} else {
if (functionFormatSpec == null) {
functionFormatSpec = SIMPLE_FUNCTION_FORMAT_SPEC;
}
printFunction(function, functionFormatSpec, context);
}
}
示例4: configure
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
protected void configure() {
functionBinder = MapBinder.newMapBinder(binder(), FunctionIdent.class, FunctionImplementation.class);
resolverBinder = MapBinder.newMapBinder(binder(), String.class, DynamicFunctionResolver.class);
IsNullPredicate.register(this);
NotPredicate.register(this);
MatchPredicate.register(this);
}
示例5: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
if (dataTypes.size() == 0) {
return new CountAggregation(COUNT_STAR_FUNCTION, false);
} else {
return new CountAggregation(
new FunctionInfo(new FunctionIdent(NAME, dataTypes),
DataTypes.LONG, FunctionInfo.Type.AGGREGATE), true);
}
}
示例6: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
checkArgument(dataTypes.size() == 2, "ANY operator requires exactly 2 arguments");
checkArgument(DataTypes.isCollectionType(dataTypes.get(1)), "The second argument to ANY must be an array or set");
checkArgument(((CollectionType) dataTypes.get(1)).innerType().equals(dataTypes.get(0)),
"The inner type of the array/set passed to ANY must match its left expression");
return newInstance(new FunctionInfo(new FunctionIdent(name(), dataTypes), BooleanType.INSTANCE));
}
示例7: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
Preconditions.checkArgument(dataTypes.size() == 2, "EqOperator must have 2 arguments");
DataType leftType = dataTypes.get(0);
DataType rightType = dataTypes.get(1);
FunctionInfo info = createInfo(dataTypes);
if (DataTypes.isCollectionType(leftType) && DataTypes.isCollectionType(rightType)) {
return new ArrayEqOperator(info);
}
if (leftType.equals(DataTypes.OBJECT) && rightType.equals(DataTypes.OBJECT)) {
return new ObjectEqOperator(info);
}
return new EqOperator(info);
}
示例8: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
validateTypes(dataTypes);
if (containsTypesWithDecimal(dataTypes)) {
return new DoubleMultiplyFunction(genDoubleInfo(NAME, dataTypes));
}
return new LongMultiplyFunction(genLongInfo(NAME, dataTypes));
}
示例9: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
validateTypes(dataTypes);
if (containsTypesWithDecimal(dataTypes)) {
return new DoubleModulusFunction(genDoubleInfo(NAME, dataTypes));
}
return new LongModulusFunction(genLongInfo(NAME, dataTypes));
}
示例10: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
validateTypes(dataTypes);
if (containsTypesWithDecimal(dataTypes)) {
return new DoubleAddFunction(genDoubleInfo(NAME, dataTypes, true));
}
return new LongAddFunction(genLongInfo(NAME, dataTypes, true));
}
示例11: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
validateTypes(dataTypes);
if (containsTypesWithDecimal(dataTypes)) {
return new DoubleDivideFunction(genDoubleInfo(NAME, dataTypes));
}
return new LongDivideFunction(genLongInfo(NAME, dataTypes));
}
示例12: getForTypes
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
validateTypes(dataTypes);
if (containsTypesWithDecimal(dataTypes)) {
return new DoubleSubtractFunction(genDoubleInfo(NAME, dataTypes));
}
return new LongSubtractFunction(genLongInfo(NAME, dataTypes));
}
示例13: normalizeFunctionSymbol
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected Symbol normalizeFunctionSymbol(Function function) {
FunctionImplementation impl = functions.get(function.info().ident());
if (impl != null) {
return impl.normalizeSymbol(function);
}
if (logger.isTraceEnabled()) {
logger.trace(SymbolFormatter.format("No implementation found for function %s", function));
}
return function;
}
示例14: createGuiceModules
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
@Override
public Collection<Module> createGuiceModules() {
LOGGER.info("Registering new scalar function using MapBinder");
return Collections.singletonList(new AbstractModule() {
@Override
protected void configure() {
MapBinder<FunctionIdent, FunctionImplementation> functionBinder =
MapBinder.newMapBinder(binder(), FunctionIdent.class, FunctionImplementation.class);
functionBinder.addBinding(new FunctionIdent(
IsEvenScalarFunction.NAME,
Collections.singletonList(DataTypes.LONG))
).toInstance(new IsEvenScalarFunction());
}
});
}
示例15: register
import io.crate.metadata.FunctionImplementation; //导入依赖的package包/类
public void register(FunctionImplementation impl) {
functionBinder.addBinding(impl.info().ident()).toInstance(impl);
}