Search in sources :

Example 31 with ILSMComponent

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

the class LSMInvertedIndexSearchCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMInvertedIndexSearchCursorInitialState lsmInitState = (LSMInvertedIndexSearchCursorInitialState) initialState;
    harness = lsmInitState.getLSMHarness();
    operationalComponents = lsmInitState.getOperationalComponents();
    indexAccessors = lsmInitState.getIndexAccessors();
    opCtx = lsmInitState.getOpContext();
    accessorIndex = 0;
    this.searchPred = searchPred;
    this.searchCallback = lsmInitState.getSearchOperationCallback();
    // For searching the deleted-keys BTrees.
    deletedKeysBTreeAccessors = lsmInitState.getDeletedKeysBTreeAccessors();
    deletedKeysBTreeCursors = new IIndexCursor[deletedKeysBTreeAccessors.size()];
    for (int i = 0; i < operationalComponents.size(); i++) {
        ILSMComponent component = operationalComponents.get(i);
        if (component.getType() == LSMComponentType.MEMORY) {
            // No need for a bloom filter for the in-memory BTree.
            deletedKeysBTreeCursors[i] = deletedKeysBTreeAccessors.get(i).createSearchCursor(false);
        } else {
            deletedKeysBTreeCursors[i] = new BloomFilterAwareBTreePointSearchCursor((IBTreeLeafFrame) lsmInitState.getgetDeletedKeysBTreeLeafFrameFactory().createFrame(), false, ((LSMInvertedIndexDiskComponent) operationalComponents.get(i)).getBloomFilter());
        }
    }
    MultiComparator keyCmp = lsmInitState.getKeyComparator();
    keySearchPred = new RangePredicate(null, null, true, true, keyCmp, keyCmp);
}
Also used : RangePredicate(org.apache.hyracks.storage.am.btree.impls.RangePredicate) IBTreeLeafFrame(org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame) MultiComparator(org.apache.hyracks.storage.common.MultiComparator) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) BloomFilterAwareBTreePointSearchCursor(org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)

Example 32 with ILSMComponent

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

the class ExternalRTree method deactivate.

@Override
public void deactivate(boolean flushOnExit) throws HyracksDataException {
    if (!isActive) {
        throw new HyracksDataException("Failed to deactivate the index since it is already deactivated.");
    }
    if (flushOnExit) {
        BlockingIOOperationCallbackWrapper cb = new BlockingIOOperationCallbackWrapper(ioOpCallback);
        cb.afterFinalize(LSMOperationType.FLUSH, null);
    }
    for (ILSMComponent c : diskComponents) {
        LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
        RTree rtree = component.getRTree();
        BTree btree = component.getBTree();
        BloomFilter bloomFilter = component.getBloomFilter();
        rtree.deactivateCloseHandle();
        btree.deactivateCloseHandle();
        bloomFilter.deactivate();
    }
    for (ILSMComponent c : secondDiskComponents) {
        // Only deactivate non shared components
        if (!diskComponents.contains(c)) {
            LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
            RTree rtree = component.getRTree();
            BTree btree = component.getBTree();
            BloomFilter bloomFilter = component.getBloomFilter();
            rtree.deactivateCloseHandle();
            btree.deactivateCloseHandle();
            bloomFilter.deactivate();
        }
    }
    isActive = false;
}
Also used : ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) BlockingIOOperationCallbackWrapper(org.apache.hyracks.storage.am.lsm.common.impls.BlockingIOOperationCallbackWrapper) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) BloomFilter(org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilter)

Example 33 with ILSMComponent

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

the class ExternalRTree method destroy.

@Override
public void destroy() throws HyracksDataException {
    if (isActive) {
        throw new HyracksDataException("Failed to destroy the index since it is activated.");
    }
    for (ILSMComponent c : diskComponents) {
        LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
        component.getRTree().destroy();
        component.getBTree().destroy();
        component.getBloomFilter().destroy();
        // Remove from second list to avoid destroying twice
        secondDiskComponents.remove(c);
    }
    for (ILSMComponent c : secondDiskComponents) {
        LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
        component.getRTree().destroy();
        component.getBTree().destroy();
        component.getBloomFilter().destroy();
    }
    diskComponents.clear();
    secondDiskComponents.clear();
    fileManager.deleteDirs();
    version = 0;
}
Also used : ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 34 with ILSMComponent

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

the class ExternalIndexHarness method exitComponents.

private void exitComponents(ILSMIndexOperationContext ctx, LSMOperationType opType, ILSMDiskComponent newComponent, boolean failedOperation) throws HyracksDataException {
    /**
         * FLUSH and MERGE operations should always exit the components
         * to notify waiting threads.
         */
    if (!ctx.isAccessingComponents() && opType != LSMOperationType.FLUSH && opType != LSMOperationType.MERGE) {
        return;
    }
    synchronized (opTracker) {
        try {
            // First check if there is any action that is needed to be taken based on the state of each component.
            for (ILSMComponent c : ctx.getComponentHolder()) {
                c.threadExit(opType, failedOperation, false);
                switch(c.getState()) {
                    case INACTIVE:
                        if (replicationEnabled) {
                            componentsToBeReplicated.clear();
                            componentsToBeReplicated.add((ILSMDiskComponent) c);
                            lsmIndex.scheduleReplication(null, componentsToBeReplicated, false, ReplicationOperation.DELETE, opType);
                        }
                        ((ILSMDiskComponent) c).destroy();
                        break;
                    default:
                        break;
                }
            }
            ctx.setAccessingComponents(false);
            // Then, perform any action that is needed to be taken based on the operation type.
            switch(opType) {
                case MERGE:
                    // newComponent is null if the merge op. was not performed.
                    if (newComponent != null) {
                        beforeSubsumeMergedComponents(newComponent, ctx.getComponentHolder());
                        lsmIndex.subsumeMergedComponents(newComponent, ctx.getComponentHolder());
                        if (replicationEnabled) {
                            componentsToBeReplicated.clear();
                            componentsToBeReplicated.add(newComponent);
                            triggerReplication(componentsToBeReplicated, false, opType);
                        }
                        mergePolicy.diskComponentAdded(lsmIndex, fullMergeIsRequested.get());
                    }
                    break;
                default:
                    break;
            }
        } finally {
            opTracker.afterOperation(lsmIndex, opType, ctx.getSearchOperationCallback(), ctx.getModificationCallback());
        }
    }
}
Also used : ILSMDiskComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)

Example 35 with ILSMComponent

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

the class ExternalIndexHarness method enterComponents.

@Override
protected boolean enterComponents(ILSMIndexOperationContext ctx, LSMOperationType opType) throws HyracksDataException {
    validateOperationEnterComponentsState(ctx);
    List<ILSMComponent> components = ctx.getComponentHolder();
    int numEntered = 0;
    boolean entranceSuccessful = false;
    try {
        for (ILSMComponent c : components) {
            if (!c.threadEnter(opType, false)) {
                break;
            }
            numEntered++;
        }
        entranceSuccessful = numEntered == components.size();
    } finally {
        if (!entranceSuccessful) {
            for (ILSMComponent c : components) {
                if (numEntered == 0) {
                    break;
                }
                c.threadExit(opType, true, false);
                numEntered--;
            }
            return false;
        }
        ctx.setAccessingComponents(true);
    }
    // Check if there is any action that is needed to be taken based on the operation type
    switch(opType) {
        case MERGE:
            lsmIndex.getIOOperationCallback().beforeOperation(LSMOperationType.MERGE);
        default:
            break;
    }
    opTracker.beforeOperation(lsmIndex, opType, ctx.getSearchOperationCallback(), ctx.getModificationCallback());
    return true;
}
Also used : ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)

Aggregations

ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)38 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)13 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)10 ILSMDiskComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent)10 IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)9 BTreeRangeSearchCursor (org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor)7 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)7 LSMComponentFileReferences (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)6 BloomFilter (org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilter)5 BloomFilterAwareBTreePointSearchCursor (org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)5 ArrayList (java.util.ArrayList)4 ILSMIndexAccessor (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor)4 RTree (org.apache.hyracks.storage.am.rtree.impls.RTree)4 ITreeIndexAccessor (org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor)3 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)3 ILSMIndexOperationContext (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext)3 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)3 ILSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId)2 BlockingIOOperationCallbackWrapper (org.apache.hyracks.storage.am.lsm.common.impls.BlockingIOOperationCallbackWrapper)2 LSMTreeIndexAccessor (org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor)2