当前位置: 首页>>代码示例>>Java>>正文


Java FunctionInfo类代码示例

本文整理汇总了Java中io.crate.metadata.FunctionInfo的典型用法代码示例。如果您正苦于以下问题:Java FunctionInfo类的具体用法?Java FunctionInfo怎么用?Java FunctionInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FunctionInfo类属于io.crate.metadata包,在下文中一共展示了FunctionInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initProxies

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
private void initProxies(Map<Function, EqProxy> existingProxies) {
    Symbol left = origin.arguments().get(0);
    DataType leftType = origin.info().ident().argumentTypes().get(0);
    DataType rightType = ((CollectionType)origin.info().ident().argumentTypes().get(1)).innerType();
    FunctionInfo eqInfo = new FunctionInfo(
            new FunctionIdent(
                    EqOperator.NAME,
                    ImmutableList.of(leftType, rightType)
            ),
            DataTypes.BOOLEAN
    );
    Literal arrayLiteral = (Literal)origin.arguments().get(1);
    proxies = new HashMap<>();
    for (Literal arrayElem : Literal.explodeCollection(arrayLiteral)) {
        Function f = new Function(eqInfo, Arrays.asList(left, arrayElem));
        EqProxy existingProxy = existingProxies.get(f);
        if (existingProxy == null) {
            existingProxy = new ChildEqProxy(f, this);
        } else if (existingProxy instanceof ChildEqProxy) {
            ((ChildEqProxy) existingProxy).addParent(this);
        }
        proxies.put(f, existingProxy);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:EqualityExtractor.java

示例2: visitFunction

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
@Override
public Void visitFunction(Function symbol, SortContext context) {
    if (!context.inFunction  && !DataTypes.PRIMITIVE_TYPES.contains(symbol.valueType())) {
        throw new UnsupportedOperationException(
                String.format(Locale.ENGLISH,
                        "Cannot ORDER BY '%s': invalid return type '%s'.",
                        SymbolPrinter.INSTANCE.printSimple(symbol),
                        symbol.valueType())
        );
    }
    if (symbol.info().type() == FunctionInfo.Type.PREDICATE) {
        throw new UnsupportedOperationException(String.format(Locale.ENGLISH,
                "%s predicate cannot be used in an ORDER BY clause", symbol.info().ident().name()));
    }
    try {
        context.inFunction = true;
        for (Symbol arg : symbol.arguments()) {
            process(arg, context);
        }
    } finally {
        context.inFunction = false;
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:SemanticSortValidator.java

示例3: register

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static void register(ScalarFunctionModule module) {
    List<DataType> supportedTimestampTypes = ImmutableList.<DataType>of(
            DataTypes.TIMESTAMP, DataTypes.LONG, DataTypes.STRING);
    for (DataType dataType : supportedTimestampTypes) {
        // without format
        module.register(new DateFormatFunction(new FunctionInfo(
                new FunctionIdent(NAME, ImmutableList.of(dataType)),
                DataTypes.STRING)
        ));
        // with format
        module.register(new DateFormatFunction(new FunctionInfo(
                new FunctionIdent(NAME, ImmutableList.of(DataTypes.STRING, dataType)),
                DataTypes.STRING)
        ));
        // time zone aware variant
        module.register(new DateFormatFunction(new FunctionInfo(
                new FunctionIdent(NAME, ImmutableList.of(DataTypes.STRING, DataTypes.STRING, dataType)),
                DataTypes.STRING)
        ));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:DateFormatFunction.java

示例4: register

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static void register(AggregationImplModule mod) {
    for (final DataType dataType : DataTypes.PRIMITIVE_TYPES) {
        mod.register(new CollectSetAggregation(new FunctionInfo(new FunctionIdent(NAME,
                ImmutableList.of(dataType)),
                new SetType(dataType), FunctionInfo.Type.AGGREGATE)));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:CollectSetAggregation.java

示例5: register

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static void register(AggregationImplModule mod) {
    for (final DataType t : DataTypes.PRIMITIVE_TYPES) {
        mod.register(new ArbitraryAggregation(
                new FunctionInfo(new FunctionIdent(NAME, ImmutableList.of(t)), t,
                                FunctionInfo.Type.AGGREGATE)));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:ArbitraryAggregation.java

示例6: register

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static void register(AggregationImplModule mod) {
    for (DataType t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
        mod.register(new SumAggregation(new FunctionInfo(new FunctionIdent(NAME, ImmutableList.of(t)),
                        DataTypes.DOUBLE, FunctionInfo.Type.AGGREGATE)));
    }

}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:SumAggregation.java

示例7: visitFunction

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
@Override
public Void visitFunction(Function symbol, OutputValidatorContext context) {
    context.insideAggregation = context.insideAggregation || symbol.info().type().equals(FunctionInfo.Type.AGGREGATE);
    for (Symbol argument : symbol.arguments()) {
        process(argument, context);
    }
    context.insideAggregation = false;
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:GlobalAggregateConsumer.java

示例8: visitComparisonExpression

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
@Override
protected Symbol visitComparisonExpression(ComparisonExpression node, ExpressionAnalysisContext context) {
    Symbol left = process(node.getLeft(), context);
    Symbol right = process(node.getRight(), context);

    if (left.valueType().equals(DataTypes.UNDEFINED) || right.valueType().equals(DataTypes.UNDEFINED)) {
        return Literal.NULL;
    }
    Comparison comparison = new Comparison(node.getType(), left, right);
    comparison.normalize(context);
    FunctionInfo info = getFunctionInfo(comparison.toFunctionIdent());
    return context.allocateFunction(info, comparison.arguments());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:ExpressionAnalyzer.java

示例9: register

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static void register(AggregationImplModule mod) {
    for (DataType<?> t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
        mod.register(new StandardDeviationAggregation(new FunctionInfo(
                new FunctionIdent(NAME, ImmutableList.<DataType>of(t)), DataTypes.DOUBLE,
                FunctionInfo.Type.AGGREGATE)));
    }
    mod.register(new StandardDeviationAggregation(new FunctionInfo(
            new FunctionIdent(NAME, ImmutableList.<DataType>of(DataTypes.TIMESTAMP)), DataTypes.DOUBLE,
            FunctionInfo.Type.AGGREGATE)));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:StandardDeviationAggregation.java

示例10: functionInfo

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static FunctionInfo functionInfo(Extract.Field field) {
    switch (field) {
        case CENTURY:
            return ExtractCentury.INFO;
        case YEAR:
            return ExtractYear.INFO;
        case QUARTER:
            return ExtractQuarter.INFO;
        case MONTH:
            return ExtractMonth.INFO;
        case WEEK:
            return ExtractWeek.INFO;
        case DAY:
        case DAY_OF_MONTH:
            return ExtractDayOfMonth.INFO;
        case DAY_OF_WEEK:
        case DOW:
            return ExtractDayOfWeek.INFO;
        case DAY_OF_YEAR:
        case DOY:
            return ExtractDayOfYear.INFO;
        case HOUR:
            return ExtractHour.INFO;
        case MINUTE:
            return ExtractMinute.INFO;
        case SECOND:
            return ExtractSecond.INFO;
        case TIMEZONE_HOUR:
            break;
        case TIMEZONE_MINUTE:
            break;
    }
    throw new UnsupportedOperationException(String.format(Locale.ENGLISH, "Extract( %s from <expression>) is not supported", field));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:ExtractFunctions.java

示例11: visitArrayComparisonExpression

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
@Override
public Symbol visitArrayComparisonExpression(ArrayComparisonExpression node, ExpressionAnalysisContext context) {
    if (node.quantifier().equals(ArrayComparisonExpression.Quantifier.ALL)) {
        throw new UnsupportedFeatureException("ALL is not supported");
    }

    Symbol arraySymbol = normalize(process(node.getRight(), context));
    Symbol leftSymbol = normalize(process(node.getLeft(), context));
    DataType rightType = arraySymbol.valueType();

    if (!DataTypes.isCollectionType(rightType)) {
        throw new IllegalArgumentException(
                SymbolFormatter.format("invalid array expression: '%s'", arraySymbol));
    }
    DataType rightInnerType = ((CollectionType) rightType).innerType();
    if (rightInnerType.equals(DataTypes.OBJECT)) {
        throw new IllegalArgumentException("ANY on object arrays is not supported");
    }

    if (arraySymbol.symbolType().isValueSymbol()) {
        arraySymbol = castIfNeededOrFail(arraySymbol, new ArrayType(leftSymbol.valueType()));
    } else {
        leftSymbol = castIfNeededOrFail(leftSymbol, rightInnerType);
    }

    ComparisonExpression.Type operationType = node.getType();
    String operatorName;
    operatorName = AnyOperator.OPERATOR_PREFIX + operationType.getValue();
    FunctionIdent functionIdent = new FunctionIdent(operatorName, Arrays.asList(leftSymbol.valueType(), arraySymbol.valueType()));
    FunctionInfo functionInfo = getFunctionInfo(functionIdent);
    return context.allocateFunction(functionInfo, Arrays.asList(leftSymbol, arraySymbol));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:ExpressionAnalyzer.java

示例12: functionInfo

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
/**
 * resolve the needed conversion function info based on the wanted return data type
 */
public static FunctionInfo functionInfo(DataType dataType, DataType returnType, boolean tryCast) {
    String functionName = FUNCTION_MAP.get(returnType);
    if (functionName == null) {
        throw new IllegalArgumentException(
                String.format(Locale.ENGLISH, "No cast function found for return type %s",
                        returnType.getName()));
    }
    functionName = tryCast ? TRY_CAST_PREFIX + functionName : functionName;
    return new FunctionInfo(new FunctionIdent(functionName, ImmutableList.of(dataType)), returnType);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:CastFunctionResolver.java

示例13: register

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
public static void register(OperatorModule module) {
    for (DataType type : DataTypes.PRIMITIVE_TYPES) {
        FunctionInfo functionInfo = new FunctionInfo(
                new FunctionIdent(NAME, ImmutableList.<DataType>of(type, new SetType(type))), DataTypes.BOOLEAN);
        module.registerOperatorFunction(new InOperator(functionInfo));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:InOperator.java

示例14: getForTypes

import io.crate.metadata.FunctionInfo; //导入依赖的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));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:AnyOperator.java

示例15: visitIsNotNullPredicate

import io.crate.metadata.FunctionInfo; //导入依赖的package包/类
@Override
protected Symbol visitIsNotNullPredicate(IsNotNullPredicate node, ExpressionAnalysisContext context) {
    Symbol argument = process(node.getValue(), context);

    FunctionIdent isNullIdent =
            new FunctionIdent(io.crate.operation.predicate.IsNullPredicate.NAME, ImmutableList.of(argument.valueType()));
    FunctionInfo isNullInfo = getFunctionInfo(isNullIdent);

    return context.allocateFunction(
            NotPredicate.INFO,
            Arrays.<Symbol>asList(context.allocateFunction(isNullInfo, Arrays.asList(argument))));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:ExpressionAnalyzer.java


注:本文中的io.crate.metadata.FunctionInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。