Search in sources :

Example 1 with CastTypeDescriptor

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 });
}
Also used : CastTypeDescriptor(org.apache.asterix.runtime.evaluators.functions.CastTypeDescriptor) AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) ColumnAccessEvalFactory(org.apache.hyracks.algebricks.runtime.evaluators.ColumnAccessEvalFactory) AssignRuntimeFactory(org.apache.hyracks.algebricks.runtime.operators.std.AssignRuntimeFactory) AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)

Aggregations

CastTypeDescriptor (org.apache.asterix.runtime.evaluators.functions.CastTypeDescriptor)1 AlgebricksPartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint)1 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)1 ColumnAccessEvalFactory (org.apache.hyracks.algebricks.runtime.evaluators.ColumnAccessEvalFactory)1 AlgebricksMetaOperatorDescriptor (org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor)1 AssignRuntimeFactory (org.apache.hyracks.algebricks.runtime.operators.std.AssignRuntimeFactory)1