Search in sources :

Example 31 with FrameTupleAccessor

use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.

the class ExternalIndexBulkModifyOperatorNodePushable method open.

// We override this method to do two things
// when creating the bulkLoader, it creates a transaction bulk loader
// It uses the bulkLoader to insert delete tuples for the deleted files
@Override
public void open() throws HyracksDataException {
    accessor = new FrameTupleAccessor(recDesc);
    indexHelper.open();
    index = indexHelper.getIndexInstance();
    try {
        writer.open();
        // Transactional BulkLoader
        bulkLoader = ((ITwoPCIndex) index).createTransactionBulkLoader(fillFactor, verifyInput, deletedFiles.length);
        // Delete files
        for (int i = 0; i < deletedFiles.length; i++) {
            fileNumber.setValue(deletedFiles[i]);
            FilesIndexDescription.getBuddyBTreeTupleFromFileNumber(deleteTuple, buddyBTreeTupleBuilder, fileNumber);
            ((ITwoPCIndexBulkLoader) bulkLoader).delete(deleteTuple);
        }
    } catch (Throwable e) {
        throw new HyracksDataException(e);
    }
}
Also used : ITwoPCIndexBulkLoader(org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)

Example 32 with FrameTupleAccessor

use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.

the class ExternalBTreeSearchOperatorNodePushable method open.

// We override the open function to search a specific version of the index
@Override
public void open() throws HyracksDataException {
    writer.open();
    accessor = new FrameTupleAccessor(inputRecDesc);
    indexHelper.open();
    index = indexHelper.getIndexInstance();
    if (retainMissing) {
        int fieldCount = getFieldCount();
        nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
        DataOutput out = nonMatchTupleBuild.getDataOutput();
        for (int i = 0; i < fieldCount; i++) {
            try {
                nonMatchWriter.writeMissing(out);
            } catch (IOException e) {
                e.printStackTrace();
            }
            nonMatchTupleBuild.addFieldEndOffset();
        }
    } else {
        nonMatchTupleBuild = null;
    }
    ExternalBTreeWithBuddy externalIndex = (ExternalBTreeWithBuddy) index;
    try {
        searchPred = createSearchPredicate();
        tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
        dos = tb.getDataOutput();
        appender = new FrameTupleAppender(new VSizeFrame(ctx));
        ISearchOperationCallback searchCallback = searchCallbackFactory.createSearchOperationCallback(indexHelper.getResource().getId(), ctx, null);
        // The next line is the reason we override this method
        indexAccessor = externalIndex.createAccessor(searchCallback, version);
        cursor = createCursor();
        if (retainInput) {
            frameTuple = new FrameTupleReference();
        }
    } catch (Throwable th) {
        throw new HyracksDataException(th);
    }
}
Also used : DataOutput(java.io.DataOutput) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) ExternalBTreeWithBuddy(org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTreeWithBuddy) FrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference) ArrayTupleBuilder(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder) IOException(java.io.IOException) ISearchOperationCallback(org.apache.hyracks.storage.common.ISearchOperationCallback) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)

Example 33 with FrameTupleAccessor

use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.

the class FeedMetaStoreNodePushable method initializeNewFeedRuntime.

private void initializeNewFeedRuntime(ActiveRuntimeId runtimeId) throws Exception {
    fta = new FrameTupleAccessor(recordDescProvider.getInputRecordDescriptor(opDesc.getActivityId(), 0));
    insertOperator.setOutputFrameWriter(0, writer, recordDesc);
    if (insertOperator instanceof LSMInsertDeleteOperatorNodePushable) {
        LSMInsertDeleteOperatorNodePushable indexOp = (LSMInsertDeleteOperatorNodePushable) insertOperator;
        if (!indexOp.isPrimary()) {
            writer = insertOperator;
            return;
        }
    }
    if (policyAccessor.flowControlEnabled()) {
        writer = new FeedRuntimeInputHandler(ctx, connectionId, runtimeId, insertOperator, policyAccessor, fta, feedManager.getFramePool());
    } else {
        writer = new SyncFeedRuntimeInputHandler(ctx, insertOperator, fta);
    }
}
Also used : LSMInsertDeleteOperatorNodePushable(org.apache.asterix.common.dataflow.LSMInsertDeleteOperatorNodePushable) SyncFeedRuntimeInputHandler(org.apache.asterix.external.feed.dataflow.SyncFeedRuntimeInputHandler) FeedRuntimeInputHandler(org.apache.asterix.external.feed.dataflow.FeedRuntimeInputHandler) SyncFeedRuntimeInputHandler(org.apache.asterix.external.feed.dataflow.SyncFeedRuntimeInputHandler) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)

Example 34 with FrameTupleAccessor

use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.

the class FrameFixedFieldTupleAppenderTest method prepareData.

private IFrameTupleAccessor prepareData(DATA_TYPE type) throws HyracksDataException {
    IFrameTupleAccessor accessor = new FrameTupleAccessor(recordDescriptor);
    IFrameTupleAppender appender = new FrameTupleAppender(new VSizeFrame(new FrameManager(INPUT_BUFFER_SIZE)), true);
    int i = 0;
    do {
        switch(type) {
            case NORMAL_RECORD:
                makeATuple(tupleBuilder, i++);
                break;
            case ONE_FIELD_LONG:
                makeASizeUpTuple(tupleBuilder, i++);
                break;
            case ONE_RECORD_LONG:
                makeABigObjectTuple(tupleBuilder, i++);
                break;
        }
    } while (appender.append(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray(), 0, tupleBuilder.getSize()));
    accessor.reset(appender.getBuffer());
    return accessor;
}
Also used : IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor) IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor)

Example 35 with FrameTupleAccessor

use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.

the class VPartitionTupleBufferManager method getTuplePointerAccessor.

@Override
public ITuplePointerAccessor getTuplePointerAccessor(final RecordDescriptor recordDescriptor) {
    return new AbstractTuplePointerAccessor() {

        FrameTupleAccessor innerAccessor = new FrameTupleAccessor(recordDescriptor);

        @Override
        IFrameTupleAccessor getInnerAccessor() {
            return innerAccessor;
        }

        @Override
        void resetInnerAccessor(TuplePointer tuplePointer) {
            partitionArray[parsePartitionId(tuplePointer.getFrameIndex())].getFrame(parseFrameIdInPartition(tuplePointer.getFrameIndex()), tempInfo);
            innerAccessor.reset(tempInfo.getBuffer(), tempInfo.getStartOffset(), tempInfo.getLength());
        }
    };
}
Also used : TuplePointer(org.apache.hyracks.dataflow.std.structures.TuplePointer) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor) IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor)

Aggregations

FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)35 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)18 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)15 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)14 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)12 FrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference)11 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)8 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)7 DataOutput (java.io.DataOutput)6 IOException (java.io.IOException)6 ByteBuffer (java.nio.ByteBuffer)6 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)6 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 FeedRuntimeInputHandler (org.apache.asterix.external.feed.dataflow.FeedRuntimeInputHandler)4 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)4 ITuplePartitionComputerFactory (org.apache.hyracks.api.dataflow.value.ITuplePartitionComputerFactory)4 IConnectorDescriptorRegistry (org.apache.hyracks.api.job.IConnectorDescriptorRegistry)4 TestFrameWriter (org.apache.hyracks.api.test.TestFrameWriter)4