Search in sources :

Example 1 with IntInnerType

use of io.ordinate.engine.schema.IntInnerType in project Mycat2 by MyCATApache.

the class CodeGenRecordSinkFactoryImpl method generateCopyRecordToVectorBatchBody.

private static BlockStatement generateCopyRecordToVectorBatchBody(IntInnerType[] types) {
    int size = types.length;
    ArrayList<Statement> statements = new ArrayList<>(size);
    for (int varIndex = 0; varIndex < size; varIndex++) {
        IntInnerType intPair = types[varIndex];
        int columnIndex = intPair.index;
        InnerType type = intPair.type;
        ConstantExpression index = Expressions.constant(columnIndex);
        ParameterExpression vectorVariable = Expressions.parameter(type.getFieldVector());
        statements.add(Expressions.declare(0, vectorVariable, Expressions.convert_(Expressions.call(input, "getVector", index), type.getFieldVector())));
        ParameterExpression returnVariable = Expressions.parameter(type.getJavaClass());
        statements.add(Expressions.declare(0, returnVariable, Expressions.call(from, "get" + type.name(), index)));
        MethodCallExpression isNullCondition = Expressions.call(from, "isNull", index);
        statements.add(Expressions.ifThenElse(isNullCondition, Expressions.statement(Expressions.call(RecordSinkFactoryImpl.class, "set" + type.getFieldVector().getSimpleName() + "Null", vectorVariable, index)), Expressions.statement(Expressions.call(RecordSinkFactoryImpl.class, "set" + type.getFieldVector().getSimpleName(), vectorVariable, rowId, returnVariable))));
    }
    return Expressions.block(statements);
}
Also used : ArrayList(java.util.ArrayList) InnerType(io.ordinate.engine.schema.InnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType)

Example 2 with IntInnerType

use of io.ordinate.engine.schema.IntInnerType in project Mycat2 by MyCATApache.

the class MapFactory method getIntPairs.

@NotNull
private static IntInnerType[] getIntPairs(InnerType[] pairs) {
    int index = 0;
    IntInnerType[] intPairs = new IntInnerType[pairs.length];
    for (InnerType pair : pairs) {
        intPairs[index] = IntInnerType.of(index, pair);
        index++;
    }
    return intPairs;
}
Also used : InnerType(io.ordinate.engine.schema.InnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with IntInnerType

use of io.ordinate.engine.schema.IntInnerType in project Mycat2 by MyCATApache.

the class MapFactory method createMap.

public static Map createMap(IntInnerType[] keys, InnerType[] values) {
    ColumnTypes keyTypes = getKeyTypes(keys);
    int[] valueTypes = Arrays.stream(values).mapToInt(i -> toQuestDbType(i)).toArray();
    int MB = 1024 * 1024;
    return new FastMap(16 * MB, keyTypes, new ColumnTypes() {

        @Override
        public int getColumnCount() {
            return valueTypes.length;
        }

        @Override
        public int getColumnType(int columnIndex) {
            return valueTypes[columnIndex];
        }
    }, 128, 0.5, 64);
}
Also used : ColumnType(io.questdb.cairo.ColumnType) ColumnTypes(io.questdb.cairo.ColumnTypes) Arrays(java.util.Arrays) InnerType(io.ordinate.engine.schema.InnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType) FastMap(io.questdb.cairo.map.FastMap) MapValue(io.questdb.cairo.map.MapValue) NotNull(org.jetbrains.annotations.NotNull) MapKey(io.questdb.cairo.map.MapKey) Map(io.questdb.cairo.map.Map) FastMap(io.questdb.cairo.map.FastMap) ColumnTypes(io.questdb.cairo.ColumnTypes)

Example 4 with IntInnerType

use of io.ordinate.engine.schema.IntInnerType in project Mycat2 by MyCATApache.

the class GroupByKeyWithAggPlan method buildRecordSink.

@NotNull
private RecordSink[] buildRecordSink(List<Field> fields) {
    RecordSink[] recordSinks = new RecordSink[groupByKeys.length];
    int groupIndex = 0;
    for (GroupKeys groupByKey : groupByKeys) {
        IntInnerType[] intPairs = new IntInnerType[groupByKey.getKeys().length];
        int[] keys = groupByKey.getKeys();
        int index = 0;
        for (int key : keys) {
            Field field = fields.get(key);
            intPairs[index] = IntInnerType.of(index, InnerType.from(field.getType()));
            index++;
        }
        recordSinks[groupIndex] = RecordSinkFactory.INSTANCE.buildRecordSink(intPairs);
        groupIndex++;
    }
    return recordSinks;
}
Also used : Field(org.apache.arrow.vector.types.pojo.Field) GroupKeys(io.ordinate.engine.builder.GroupKeys) IntInnerType(io.ordinate.engine.schema.IntInnerType) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with IntInnerType

use of io.ordinate.engine.schema.IntInnerType in project Mycat2 by MyCATApache.

the class FooRecordSink method copy.

@Override
public void copy(Record r, RecordSetter w) {
    for (IntInnerType intPair : types) {
        int i = intPair.index;
        boolean aNull = r.isNull(i);
        if (aNull) {
            copyNullType(r, w, i);
            continue;
        }
        InnerType innerType = intPair.type;
        switch(innerType) {
            case BOOLEAN_TYPE:
                copyBooleanType(r, w, i);
                break;
            case INT8_TYPE:
                copyInt8Type(r, w, i);
                break;
            case INT16_TYPE:
                copyInt16Type(r, w, i);
                break;
            case CHAR_TYPE:
                copyCharType(r, w, i);
                break;
            case INT32_TYPE:
                copyInt32Type(r, w, i);
                break;
            case INT64_TYPE:
                copyInt64Type(r, w, i);
                break;
            case FLOAT_TYPE:
                copyFloatType(r, w, i);
                break;
            case DOUBLE_TYPE:
                copyDoubleType(r, w, i);
                break;
            case STRING_TYPE:
                copyStringType(r, w, i);
                break;
            case BINARY_TYPE:
                copyBinaryType(r, w, i);
                break;
            case UINT8_TYPE:
                copyUInt8Type(r, w, i);
                break;
            case UINT16_TYPE:
                copyUInt16Type(r, w, i);
                break;
            case UINT32_TYPE:
                copyUInt32Type(r, w, i);
                break;
            case UINT64_TYPE:
                copyUInt64Type(r, w, i);
                break;
            case TIME_MILLI_TYPE:
                copyTimeMillType(r, w, i);
                break;
            case DATE_TYPE:
                copyDateType(r, w, i);
                break;
            case DATETIME_MILLI_TYPE:
                copyDatetimeMilliType(r, w, i);
                break;
            case SYMBOL_TYPE:
                copySymbolType(r, w, i);
                break;
            case OBJECT_TYPE:
                copyObjectType(r, w, i);
                break;
            case NULL_TYPE:
                copyNullType(r, w, i);
                break;
        }
    }
}
Also used : InnerType(io.ordinate.engine.schema.InnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType) IntInnerType(io.ordinate.engine.schema.IntInnerType)

Aggregations

IntInnerType (io.ordinate.engine.schema.IntInnerType)10 InnerType (io.ordinate.engine.schema.InnerType)7 Map (io.questdb.cairo.map.Map)3 MapKey (io.questdb.cairo.map.MapKey)3 NotNull (org.jetbrains.annotations.NotNull)3 GroupKeys (io.ordinate.engine.builder.GroupKeys)2 RecordSetter (io.ordinate.engine.record.RecordSetter)2 RecordSink (io.ordinate.engine.record.RecordSink)2 RecordSinkFactory (io.ordinate.engine.record.RecordSinkFactory)2 RootContext (io.ordinate.engine.record.RootContext)2 VectorBatchRecord (io.ordinate.engine.record.VectorBatchRecord)2 MapFactory (io.ordinate.engine.structure.MapFactory)2 Observable (io.reactivex.rxjava3.core.Observable)2 Action (io.reactivex.rxjava3.functions.Action)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 VectorSchemaRoot (org.apache.arrow.vector.VectorSchemaRoot)2 Field (org.apache.arrow.vector.types.pojo.Field)2 Schema (org.apache.arrow.vector.types.pojo.Schema)2