Search in sources :

Example 16 with AlgebricksMetaOperatorDescriptor

use of org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor in project asterixdb by apache.

the class SecondaryIndexOperationsHelper method createAssignOp.

protected AlgebricksMetaOperatorDescriptor createAssignOp(JobSpecification spec, int numSecondaryKeyFields, RecordDescriptor secondaryRecDesc) throws AlgebricksException {
    int[] outColumns = new int[numSecondaryKeyFields + numFilterFields];
    int[] projectionList = new int[numSecondaryKeyFields + numPrimaryKeys + numFilterFields];
    for (int i = 0; i < numSecondaryKeyFields + numFilterFields; i++) {
        outColumns[i] = numPrimaryKeys + i;
    }
    int projCount = 0;
    for (int i = 0; i < numSecondaryKeyFields; i++) {
        projectionList[projCount++] = numPrimaryKeys + i;
    }
    for (int i = 0; i < numPrimaryKeys; i++) {
        projectionList[projCount++] = i;
    }
    if (numFilterFields > 0) {
        projectionList[projCount] = numPrimaryKeys + numSecondaryKeyFields;
    }
    IScalarEvaluatorFactory[] sefs = new IScalarEvaluatorFactory[secondaryFieldAccessEvalFactories.length];
    for (int i = 0; i < secondaryFieldAccessEvalFactories.length; ++i) {
        sefs[i] = secondaryFieldAccessEvalFactories[i];
    }
    AssignRuntimeFactory assign = new AssignRuntimeFactory(outColumns, sefs, projectionList);
    AlgebricksMetaOperatorDescriptor asterixAssignOp = new AlgebricksMetaOperatorDescriptor(spec, 1, 1, new IPushRuntimeFactory[] { assign }, new RecordDescriptor[] { secondaryRecDesc });
    AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, asterixAssignOp, primaryPartitionConstraint);
    return asterixAssignOp;
}
Also used : AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) 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)

Example 17 with AlgebricksMetaOperatorDescriptor

use of org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor 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)

Example 18 with AlgebricksMetaOperatorDescriptor

use of org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor in project asterixdb by apache.

the class FlushDatasetUtil method flushDataset.

public static void flushDataset(IHyracksClientConnection hcc, MetadataProvider metadataProvider, String dataverseName, String datasetName, String indexName) throws Exception {
    CompilerProperties compilerProperties = metadataProvider.getApplicationContext().getCompilerProperties();
    int frameSize = compilerProperties.getFrameSize();
    JobSpecification spec = new JobSpecification(frameSize);
    RecordDescriptor[] rDescs = new RecordDescriptor[] { new RecordDescriptor(new ISerializerDeserializer[] {}) };
    AlgebricksMetaOperatorDescriptor emptySource = new AlgebricksMetaOperatorDescriptor(spec, 0, 1, new IPushRuntimeFactory[] { new EmptyTupleSourceRuntimeFactory() }, rDescs);
    org.apache.asterix.common.transactions.JobId jobId = JobIdFactory.generateJobId();
    Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
    FlushDatasetOperatorDescriptor flushOperator = new FlushDatasetOperatorDescriptor(spec, jobId, dataset.getDatasetId());
    spec.connect(new OneToOneConnectorDescriptor(spec), emptySource, 0, flushOperator, 0);
    Pair<IFileSplitProvider, AlgebricksPartitionConstraint> primarySplitsAndConstraint = metadataProvider.getSplitProviderAndConstraints(dataset, indexName);
    AlgebricksPartitionConstraint primaryPartitionConstraint = primarySplitsAndConstraint.second;
    AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, emptySource, primaryPartitionConstraint);
    JobEventListenerFactory jobEventListenerFactory = new JobEventListenerFactory(jobId, true);
    spec.setJobletEventListenerFactory(jobEventListenerFactory);
    JobUtils.runJob(hcc, spec, true);
}
Also used : RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) Dataset(org.apache.asterix.metadata.entities.Dataset) IFileSplitProvider(org.apache.hyracks.dataflow.std.file.IFileSplitProvider) AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) CompilerProperties(org.apache.asterix.common.config.CompilerProperties) OneToOneConnectorDescriptor(org.apache.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor) JobEventListenerFactory(org.apache.asterix.runtime.job.listener.JobEventListenerFactory) AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) FlushDatasetOperatorDescriptor(org.apache.asterix.runtime.operators.std.FlushDatasetOperatorDescriptor) EmptyTupleSourceRuntimeFactory(org.apache.hyracks.algebricks.runtime.operators.std.EmptyTupleSourceRuntimeFactory) AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) JobSpecification(org.apache.hyracks.api.job.JobSpecification)

Example 19 with AlgebricksMetaOperatorDescriptor

use of org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor in project asterixdb by apache.

the class JobBuilder method buildAsterixComponents.

private void buildAsterixComponents() {
    for (ILogicalOperator aop : microOps.keySet()) {
        addMicroOpToMetaRuntimeOp(aop);
    }
    for (Integer k : metaAsterixOpSkeletons.keySet()) {
        List<Pair<IPushRuntimeFactory, RecordDescriptor>> opContents = metaAsterixOpSkeletons.get(k);
        AlgebricksMetaOperatorDescriptor amod = buildMetaAsterixOpDesc(opContents);
        metaAsterixOps.put(k, amod);
    }
}
Also used : ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 20 with AlgebricksMetaOperatorDescriptor

use of org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor in project asterixdb by apache.

the class JobBuilder method buildMetaAsterixOpDesc.

private AlgebricksMetaOperatorDescriptor buildMetaAsterixOpDesc(List<Pair<IPushRuntimeFactory, RecordDescriptor>> opContents) {
    int n = opContents.size();
    IPushRuntimeFactory[] runtimeFactories = new IPushRuntimeFactory[n];
    RecordDescriptor[] internalRecordDescriptors = new RecordDescriptor[n];
    int i = 0;
    for (Pair<IPushRuntimeFactory, RecordDescriptor> p : opContents) {
        runtimeFactories[i] = p.first;
        internalRecordDescriptors[i] = p.second;
        i++;
    }
    ILogicalOperator lastLogicalOp = revMicroOpMap.get(runtimeFactories[n - 1]);
    ArrayList<ILogicalOperator> outOps = outEdges.get(lastLogicalOp);
    int outArity = (outOps == null) ? 0 : outOps.size();
    ILogicalOperator firstLogicalOp = revMicroOpMap.get(runtimeFactories[0]);
    ArrayList<ILogicalOperator> inOps = inEdges.get(firstLogicalOp);
    int inArity = (inOps == null) ? 0 : inOps.size();
    return new AlgebricksMetaOperatorDescriptor(jobSpec, inArity, outArity, runtimeFactories, internalRecordDescriptors);
}
Also used : RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) IPushRuntimeFactory(org.apache.hyracks.algebricks.runtime.base.IPushRuntimeFactory) AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) AlgebricksAbsolutePartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint) AlgebricksCountPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint)

Aggregations

AlgebricksMetaOperatorDescriptor (org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor)27 JobSpecification (org.apache.hyracks.api.job.JobSpecification)19 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)16 Test (org.junit.Test)13 File (java.io.File)12 SinkWriterRuntimeFactory (org.apache.hyracks.algebricks.runtime.operators.std.SinkWriterRuntimeFactory)12 OneToOneConnectorDescriptor (org.apache.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor)11 AlgebricksPartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint)9 AssignRuntimeFactory (org.apache.hyracks.algebricks.runtime.operators.std.AssignRuntimeFactory)8 EmptyTupleSourceRuntimeFactory (org.apache.hyracks.algebricks.runtime.operators.std.EmptyTupleSourceRuntimeFactory)8 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)7 IValueParserFactory (org.apache.hyracks.dataflow.common.data.parsers.IValueParserFactory)7 DelimitedDataTupleParserFactory (org.apache.hyracks.dataflow.std.file.DelimitedDataTupleParserFactory)7 IFileSplitProvider (org.apache.hyracks.dataflow.std.file.IFileSplitProvider)7 FileSplit (org.apache.hyracks.api.io.FileSplit)6 ManagedFileSplit (org.apache.hyracks.api.io.ManagedFileSplit)6 ConstantFileSplitProvider (org.apache.hyracks.dataflow.std.file.ConstantFileSplitProvider)6 FileScanOperatorDescriptor (org.apache.hyracks.dataflow.std.file.FileScanOperatorDescriptor)6 IOperatorDescriptor (org.apache.hyracks.api.dataflow.IOperatorDescriptor)5 UTF8StringSerializerDeserializer (org.apache.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer)5