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);
}
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;
}
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);
}
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;
}
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;
}
}
}
Aggregations