Search in sources :

Example 6 with IIndexDataflowHelper

use of org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper in project asterixdb by apache.

the class ExternalFilesIndexCreateOperatorDescriptor method createPushRuntime.

@Override
public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx, IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
    return new AbstractOperatorNodePushable() {

        @Override
        public void initialize() throws HyracksDataException {
            IIndexBuilder indexBuilder = indexBuilderFactory.create(ctx, partition);
            IIndexDataflowHelper indexHelper = dataflowHelperFactory.create(ctx, partition);
            FileIndexTupleTranslator filesTupleTranslator = new FileIndexTupleTranslator();
            // Build the index
            indexBuilder.build();
            // Open the index
            indexHelper.open();
            try {
                IIndex index = indexHelper.getIndexInstance();
                // Create bulk loader
                IIndexBulkLoader bulkLoader = index.createBulkLoader(BTree.DEFAULT_FILL_FACTOR, false, files.size(), false);
                // Load files
                for (ExternalFile file : files) {
                    bulkLoader.add(filesTupleTranslator.getTupleFromFile(file));
                }
                bulkLoader.end();
            } finally {
                indexHelper.close();
            }
        }

        @Override
        public void deinitialize() throws HyracksDataException {
        }

        @Override
        public int getInputArity() {
            return 0;
        }

        @Override
        public void setOutputFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc) throws HyracksDataException {
        }

        @Override
        public IFrameWriter getInputFrameWriter(int index) {
            return null;
        }
    };
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) IIndexBuilder(org.apache.hyracks.storage.am.common.api.IIndexBuilder) IFrameWriter(org.apache.hyracks.api.comm.IFrameWriter) FileIndexTupleTranslator(org.apache.asterix.external.indexing.FileIndexTupleTranslator) IIndexDataflowHelper(org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper) AbstractOperatorNodePushable(org.apache.hyracks.dataflow.std.base.AbstractOperatorNodePushable) IIndexBulkLoader(org.apache.hyracks.storage.common.IIndexBulkLoader) RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) ExternalFile(org.apache.asterix.external.indexing.ExternalFile)

Aggregations

IIndexDataflowHelper (org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper)6 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)3 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)3 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 AbstractOperatorNodePushable (org.apache.hyracks.dataflow.std.base.AbstractOperatorNodePushable)3 ExternalFile (org.apache.asterix.external.indexing.ExternalFile)2 FileIndexTupleTranslator (org.apache.asterix.external.indexing.FileIndexTupleTranslator)2 IIndex (org.apache.hyracks.storage.common.IIndex)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TestNodeController (org.apache.asterix.app.bootstrap.TestNodeController)1 TestTupleCounterFrameWriter (org.apache.asterix.app.data.gen.TestTupleCounterFrameWriter)1 TupleGenerator (org.apache.asterix.app.data.gen.TupleGenerator)1 LSMInsertDeleteOperatorNodePushable (org.apache.asterix.common.dataflow.LSMInsertDeleteOperatorNodePushable)1 ILogRecord (org.apache.asterix.common.transactions.ILogRecord)1 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)1 StorageComponentProvider (org.apache.asterix.file.StorageComponentProvider)1 Dataset (org.apache.asterix.metadata.entities.Dataset)1 InternalDatasetDetails (org.apache.asterix.metadata.entities.InternalDatasetDetails)1 LogReader (org.apache.asterix.transaction.management.service.logging.LogReader)1