use of org.apache.asterix.runtime.evaluators.functions.CastTypeDescriptor in project asterixdb by apache.
the class SecondaryIndexOperationsHelper method createCastOp.
protected AlgebricksMetaOperatorDescriptor createCastOp(JobSpecification spec, DatasetType dsType) {
CastTypeDescriptor castFuncDesc = (CastTypeDescriptor) CastTypeDescriptor.FACTORY.createFunctionDescriptor();
castFuncDesc.setImmutableStates(enforcedItemType, itemType);
int[] outColumns = new int[1];
int[] projectionList = new int[(dataset.hasMetaPart() ? 2 : 1) + numPrimaryKeys];
int recordIdx;
//external datascan operator returns a record as the first field, instead of the last in internal case
if (dsType == DatasetType.EXTERNAL) {
recordIdx = 0;
outColumns[0] = 0;
} else {
recordIdx = numPrimaryKeys;
outColumns[0] = numPrimaryKeys;
}
for (int i = 0; i <= numPrimaryKeys; i++) {
projectionList[i] = i;
}
if (dataset.hasMetaPart()) {
projectionList[numPrimaryKeys + 1] = numPrimaryKeys + 1;
}
IScalarEvaluatorFactory[] castEvalFact = new IScalarEvaluatorFactory[] { new ColumnAccessEvalFactory(recordIdx) };
IScalarEvaluatorFactory[] sefs = new IScalarEvaluatorFactory[1];
sefs[0] = castFuncDesc.createEvaluatorFactory(castEvalFact);
AssignRuntimeFactory castAssign = new AssignRuntimeFactory(outColumns, sefs, projectionList);
return new AlgebricksMetaOperatorDescriptor(spec, 1, 1, new IPushRuntimeFactory[] { castAssign }, new RecordDescriptor[] { enforcedRecDesc });
}
Aggregations