// eval.add(getValueAccessor.arg(indexVariable).arg(out.getHolder()));
public static void read(MajorType type, JExpression vector, JBlock eval, HoldingContainer out, JCodeModel model,
JExpression indexVariable) {
JInvocation getValueAccessor = vector.invoke("getAccessor");
switch(type.getMode()){
case OPTIONAL:
eval.assign(out.getIsSet(), getValueAccessor.invoke("isSet").arg(indexVariable));
eval = eval._if(out.getIsSet().eq(JExpr.lit(1)))._then();
// fall through
case REQUIRED:
switch (type.getMinorType()) {
case BIGINT:
case FLOAT4:
case FLOAT8:
case INT:
case MONEY:
case SMALLINT:
case TINYINT:
case UINT1:
case UINT2:
case UINT4:
case UINT8:
case INTERVALYEAR:
case DATE:
case TIME:
case TIMESTAMP:
case BIT:
eval.assign(out.getValue(), getValueAccessor.invoke("get").arg(indexVariable));
return;
case DECIMAL9:
case DECIMAL18:
eval.assign(out.getHolder().ref("scale"), vector.invoke("getField").invoke("getScale"));
eval.assign(out.getHolder().ref("precision"), vector.invoke("getField").invoke("getPrecision"));
eval.assign(out.getValue(), getValueAccessor.invoke("get").arg(indexVariable));
return;
case DECIMAL28DENSE:
case DECIMAL28SPARSE:
case DECIMAL38DENSE:
case DECIMAL38SPARSE:
eval.assign(out.getHolder().ref("scale"), vector.invoke("getField").invoke("getScale"));
eval.assign(out.getHolder().ref("precision"), vector.invoke("getField").invoke("getPrecision"));
eval.assign(out.getHolder().ref("start"), JExpr.lit(TypeHelper.getSize(type)).mul(indexVariable));
eval.assign(out.getHolder().ref("buffer"), vector.invoke("getData"));
return;
case INTERVAL:{
JVar start = eval.decl(model.INT, "start", JExpr.lit(TypeHelper.getSize(type)).mul(indexVariable));
JVar data = eval.decl(model.ref(DrillBuf.class), "data", vector.invoke("getData"));
eval.assign(out.getHolder().ref("months"), data.invoke("getInt").arg(start));
eval.assign(out.getHolder().ref("days"), data.invoke("getInt").arg(start.plus(JExpr.lit(4))));
eval.assign(out.getHolder().ref("milliseconds"), data.invoke("getInt").arg(start.plus(JExpr.lit(8))));
return;
}
case INTERVALDAY: {
JVar start = eval.decl(model.INT, "start", JExpr.lit(TypeHelper.getSize(type)).mul(indexVariable));
eval.assign(out.getHolder().ref("days"), vector.invoke("getData").invoke("getInt").arg(start));
eval.assign(out.getHolder().ref("milliseconds"), vector.invoke("getData").invoke("getInt").arg(start.plus(JExpr.lit(4))));
return;
}
case VAR16CHAR:
case VARBINARY:
case VARCHAR:
eval.assign(out.getHolder().ref("buffer"), vector.invoke("getData"));
JVar se = eval.decl(model.LONG, "startEnd", getValueAccessor.invoke("getStartEnd").arg(indexVariable));
eval.assign(out.getHolder().ref("start"), JExpr.cast(model._ref(int.class), se));
eval.assign(out.getHolder().ref("end"), JExpr.cast(model._ref(int.class), se.shr(JExpr.lit(32))));
return;
}
}
// fallback.
eval.add(getValueAccessor.invoke("get").arg(indexVariable).arg(out.getHolder()));
}