Search in sources :

Example 66 with DataType

use of io.crate.types.DataType in project crate by crate.

the class TrigonometricFunctions method register.

private static void register(ScalarFunctionModule module, String name, DoubleUnaryOperator func) {
    for (DataType inputType : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
        FunctionIdent ident = new FunctionIdent(name, Collections.singletonList(inputType));
        module.register(new DoubleScalar(new FunctionInfo(ident, DataTypes.DOUBLE), func));
    }
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) DataType(io.crate.types.DataType) FunctionInfo(io.crate.metadata.FunctionInfo) DoubleScalar(io.crate.operation.scalar.DoubleScalar)

Example 67 with DataType

use of io.crate.types.DataType in project crate by crate.

the class CastFunctionResolver method generateCastFunction.

public static Symbol generateCastFunction(Symbol sourceSymbol, DataType targetType, boolean tryCast) {
    DataType sourceType = sourceSymbol.valueType();
    FunctionInfo functionInfo = functionInfo(sourceType, targetType, tryCast);
    //noinspection ArraysAsListWithZeroOrOneArgument  # arguments of Function must be mutable
    return new io.crate.analyze.symbol.Function(functionInfo, Arrays.asList(sourceSymbol));
}
Also used : Function(com.google.common.base.Function) DataType(io.crate.types.DataType) FunctionInfo(io.crate.metadata.FunctionInfo)

Example 68 with DataType

use of io.crate.types.DataType in project crate by crate.

the class CoordinateFunction method register.

private static void register(ScalarFunctionModule module, String name, Function<Object, Double> func) {
    for (DataType inputType : SUPPORTED_INPUT_TYPES) {
        FunctionIdent ident = new FunctionIdent(name, Collections.singletonList(inputType));
        module.register(new UnaryScalar<>(new FunctionInfo(ident, DataTypes.DOUBLE), func));
    }
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) DataType(io.crate.types.DataType) FunctionInfo(io.crate.metadata.FunctionInfo)

Example 69 with DataType

use of io.crate.types.DataType in project crate by crate.

the class GeoHashFunction method register.

private static void register(ScalarFunctionModule module, String name, Function<Object, BytesRef> func) {
    for (DataType inputType : SUPPORTED_INPUT_TYPES) {
        FunctionIdent ident = new FunctionIdent(name, Collections.singletonList(inputType));
        module.register(new UnaryScalar<>(new FunctionInfo(ident, DataTypes.STRING), func));
    }
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) DataType(io.crate.types.DataType) FunctionInfo(io.crate.metadata.FunctionInfo)

Example 70 with DataType

use of io.crate.types.DataType in project crate by crate.

the class MergePhase method writeTo.

@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    distributionInfo.writeTo(out);
    out.writeVInt(numUpstreams);
    int numCols = inputTypes.size();
    out.writeVInt(numCols);
    for (DataType inputType : inputTypes) {
        DataTypes.toStream(inputType, out);
    }
    if (executionNodes == null) {
        out.writeVInt(0);
    } else {
        out.writeVInt(executionNodes.size());
        for (String node : executionNodes) {
            out.writeString(node);
        }
    }
    PositionalOrderBy.toStream(positionalOrderBy, out);
}
Also used : DataType(io.crate.types.DataType)

Aggregations

DataType (io.crate.types.DataType)95 ArrayType (io.crate.types.ArrayType)35 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)17 Map (java.util.Map)17 CrateUnitTest (io.crate.test.integration.CrateUnitTest)14 List (java.util.List)12 Symbol (io.crate.expression.symbol.Symbol)11 Literal (io.crate.expression.symbol.Literal)9 ColumnIdent (io.crate.metadata.ColumnIdent)9 HashMap (java.util.HashMap)9 FunctionIdent (io.crate.metadata.FunctionIdent)8 NodeContext (io.crate.metadata.NodeContext)8 Reference (io.crate.metadata.Reference)8 Row (io.crate.data.Row)7 Symbols (io.crate.expression.symbol.Symbols)7 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)7 Locale (java.util.Locale)7 Lists2 (io.crate.common.collections.Lists2)6 FunctionInfo (io.crate.metadata.FunctionInfo)6