Search in sources :

Example 1 with MergeOperation

use of org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation in project asterixdb by apache.

the class LSMRTreeWithAntiMatterTuples method merge.

@Override
public ILSMDiskComponent merge(ILSMIOOperation operation) throws HyracksDataException {
    MergeOperation mergeOp = (MergeOperation) operation;
    IIndexCursor cursor = mergeOp.getCursor();
    ISearchPredicate rtreeSearchPred = new SearchPredicate(null, null);
    ILSMIndexOperationContext opCtx = ((LSMIndexSearchCursor) cursor).getOpCtx();
    opCtx.getComponentHolder().addAll(mergeOp.getMergingComponents());
    search(opCtx, cursor, rtreeSearchPred);
    // Bulk load the tuples from all on-disk RTrees into the new RTree.
    LSMRTreeDiskComponent component = createDiskComponent(componentFactory, mergeOp.getTarget(), null, null, true);
    ILSMDiskComponentBulkLoader componentBulkLoader = createComponentBulkLoader(component, 1.0f, false, 0L, false, false);
    try {
        while (cursor.hasNext()) {
            cursor.next();
            ITupleReference frameTuple = cursor.getTuple();
            componentBulkLoader.add(frameTuple);
        }
    } finally {
        cursor.close();
    }
    if (component.getLSMComponentFilter() != null) {
        List<ITupleReference> filterTuples = new ArrayList<>();
        for (int i = 0; i < mergeOp.getMergingComponents().size(); ++i) {
            filterTuples.add(mergeOp.getMergingComponents().get(i).getLSMComponentFilter().getMinTuple());
            filterTuples.add(mergeOp.getMergingComponents().get(i).getLSMComponentFilter().getMaxTuple());
        }
        getFilterManager().updateFilter(component.getLSMComponentFilter(), filterTuples);
        getFilterManager().writeFilter(component.getLSMComponentFilter(), component.getRTree());
    }
    componentBulkLoader.end();
    return component;
}
Also used : MergeOperation(org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) IIndexCursor(org.apache.hyracks.storage.common.IIndexCursor) ILSMIndexOperationContext(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext) LSMIndexSearchCursor(org.apache.hyracks.storage.am.lsm.common.impls.LSMIndexSearchCursor) ILSMDiskComponentBulkLoader(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentBulkLoader) ISearchPredicate(org.apache.hyracks.storage.common.ISearchPredicate) SearchPredicate(org.apache.hyracks.storage.am.rtree.impls.SearchPredicate) ISearchPredicate(org.apache.hyracks.storage.common.ISearchPredicate)

Example 2 with MergeOperation

use of org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation in project asterixdb by apache.

the class LSMRTreeWithAntiMatterTuples method createMergeOperation.

@Override
protected ILSMIOOperation createMergeOperation(AbstractLSMIndexOperationContext opCtx, List<ILSMComponent> mergingComponents, LSMComponentFileReferences mergeFileRefs, ILSMIOOperationCallback callback) throws HyracksDataException {
    boolean returnDeletedTuples = false;
    if (mergingComponents.get(mergingComponents.size() - 1) != diskComponents.get(diskComponents.size() - 1)) {
        returnDeletedTuples = true;
    }
    ITreeIndexCursor cursor = new LSMRTreeWithAntiMatterTuplesSearchCursor(opCtx, returnDeletedTuples);
    ILSMIndexAccessor accessor = new LSMTreeIndexAccessor(getLsmHarness(), opCtx, cursorFactory);
    return new MergeOperation(accessor, mergeFileRefs.getInsertIndexFileReference(), callback, fileManager.getBaseDir(), mergingComponents, cursor);
}
Also used : ITreeIndexCursor(org.apache.hyracks.storage.am.common.api.ITreeIndexCursor) MergeOperation(org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation) LSMTreeIndexAccessor(org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor) ILSMIndexAccessor(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)

Aggregations

MergeOperation (org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation)2 ArrayList (java.util.ArrayList)1 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)1 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)1 ILSMDiskComponentBulkLoader (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentBulkLoader)1 ILSMIndexAccessor (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)1 ILSMIndexOperationContext (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext)1 LSMIndexSearchCursor (org.apache.hyracks.storage.am.lsm.common.impls.LSMIndexSearchCursor)1 LSMTreeIndexAccessor (org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor)1 SearchPredicate (org.apache.hyracks.storage.am.rtree.impls.SearchPredicate)1 IIndexCursor (org.apache.hyracks.storage.common.IIndexCursor)1 ISearchPredicate (org.apache.hyracks.storage.common.ISearchPredicate)1