Search in sources :

Example 1 with BloomFilterAwareBTreePointSearchCursor

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

the class LSMBTreeWithBuddyAbstractCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMBTreeWithBuddyCursorInitialState lsmInitialState = (LSMBTreeWithBuddyCursorInitialState) initialState;
    btreeCmp = lsmInitialState.getBTreeCmp();
    buddyBtreeCmp = lsmInitialState.getBuddyBTreeCmp();
    operationalComponents = lsmInitialState.getOperationalComponents();
    lsmHarness = lsmInitialState.getLSMHarness();
    numberOfTrees = operationalComponents.size();
    if (btreeCursors == null || btreeCursors.length != numberOfTrees) {
        // need to re-use the following four instead of re-creating
        btreeCursors = new BTreeRangeSearchCursor[numberOfTrees];
        buddyBtreeCursors = new BTreeRangeSearchCursor[numberOfTrees];
        btreeAccessors = new BTreeAccessor[numberOfTrees];
        buddyBtreeAccessors = new BTreeAccessor[numberOfTrees];
    }
    includeMutableComponent = false;
    for (int i = 0; i < numberOfTrees; i++) {
        ILSMComponent component = operationalComponents.get(i);
        BTree btree;
        BTree buddyBtree;
        if (component.getType() == LSMComponentType.MEMORY) {
            // This is not needed at the moment but is implemented anyway
            includeMutableComponent = true;
            // No need for a bloom filter for the in-memory BTree.
            if (buddyBtreeCursors[i] == null || buddyBtreeCursors[i].isBloomFilterAware()) {
                buddyBtreeCursors[i] = new BTreeRangeSearchCursor((IBTreeLeafFrame) lsmInitialState.getBuddyBTreeLeafFrameFactory().createFrame(), false);
            } else {
                buddyBtreeCursors[i].reset();
            }
            btree = ((LSMBTreeWithBuddyMemoryComponent) component).getBTree();
            buddyBtree = ((LSMBTreeWithBuddyMemoryComponent) component).getBuddyBTree();
        } else {
            if (buddyBtreeCursors[i] == null || !buddyBtreeCursors[i].isBloomFilterAware()) {
                buddyBtreeCursors[i] = new BloomFilterAwareBTreePointSearchCursor((IBTreeLeafFrame) lsmInitialState.getBuddyBTreeLeafFrameFactory().createFrame(), false, ((LSMBTreeWithBuddyDiskComponent) operationalComponents.get(i)).getBloomFilter());
            } else {
                buddyBtreeCursors[i].reset();
            }
            btree = ((LSMBTreeWithBuddyDiskComponent) component).getBTree();
            buddyBtree = ((LSMBTreeWithBuddyDiskComponent) component).getBuddyBTree();
        }
        IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) lsmInitialState.getBTreeLeafFrameFactory().createFrame();
        if (btreeAccessors[i] == null) {
            btreeCursors[i] = new BTreeRangeSearchCursor(leafFrame, false);
            btreeAccessors[i] = (BTreeAccessor) btree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            buddyBtreeAccessors[i] = (BTreeAccessor) buddyBtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        } else {
            btreeCursors[i].reset();
            btreeAccessors[i].reset(btree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            buddyBtreeAccessors[i].reset(buddyBtree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        }
    }
    btreeRangePredicate = (RangePredicate) searchPred;
    buddyBtreeRangePredicate.reset(null, null, true, true, buddyBtreeCmp, buddyBtreeCmp);
    open = true;
}
Also used : BTreeRangeSearchCursor(org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor) IBTreeLeafFrame(org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) BloomFilterAwareBTreePointSearchCursor(org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)

Example 2 with BloomFilterAwareBTreePointSearchCursor

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

the class LSMRTreeAbstractCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMRTreeCursorInitialState lsmInitialState = (LSMRTreeCursorInitialState) initialState;
    if (btreeCmp == null) {
        btreeCmp = lsmInitialState.getBTreeCmp();
        btreeRangePredicate.setLowKeyCmp(btreeCmp);
        btreeRangePredicate.setHighKeyCmp(btreeCmp);
    }
    operationalComponents = lsmInitialState.getOperationalComponents();
    lsmHarness = lsmInitialState.getLSMHarness();
    numberOfTrees = operationalComponents.size();
    int numComponenets = operationalComponents.size();
    if (rtreeCursors == null || rtreeCursors.length != numComponenets) {
        // object creation: should be relatively low
        rtreeCursors = new RTreeSearchCursor[numberOfTrees];
        btreeCursors = new BTreeRangeSearchCursor[numberOfTrees];
        rtreeAccessors = new RTreeAccessor[numberOfTrees];
        btreeAccessors = new BTreeAccessor[numberOfTrees];
    }
    includeMutableComponent = false;
    for (int i = 0; i < numberOfTrees; i++) {
        ILSMComponent component = operationalComponents.get(i);
        RTree rtree;
        BTree btree;
        if (component.getType() == LSMComponentType.MEMORY) {
            includeMutableComponent = true;
            // No need for a bloom filter for the in-memory BTree.
            if (btreeCursors[i] == null || btreeCursors[i].isBloomFilterAware()) {
                //create
                btreeCursors[i] = new BTreeRangeSearchCursor((IBTreeLeafFrame) lsmInitialState.getBTreeLeafFrameFactory().createFrame(), false);
            } else {
                //re-use
                btreeCursors[i].reset();
            }
            rtree = ((LSMRTreeMemoryComponent) component).getRTree();
            btree = ((LSMRTreeMemoryComponent) component).getBTree();
        } else {
            if (btreeCursors[i] == null || !btreeCursors[i].isBloomFilterAware()) {
                // need to create a new one
                btreeCursors[i] = new BloomFilterAwareBTreePointSearchCursor((IBTreeLeafFrame) lsmInitialState.getBTreeLeafFrameFactory().createFrame(), false, ((LSMRTreeDiskComponent) operationalComponents.get(i)).getBloomFilter());
            } else {
                // reset
                ((BloomFilterAwareBTreePointSearchCursor) btreeCursors[i]).resetBloomFilter(((LSMRTreeDiskComponent) operationalComponents.get(i)).getBloomFilter());
                btreeCursors[i].reset();
            }
            rtree = ((LSMRTreeDiskComponent) component).getRTree();
            btree = ((LSMRTreeDiskComponent) component).getBTree();
        }
        if (rtreeCursors[i] == null) {
            rtreeCursors[i] = new RTreeSearchCursor((IRTreeInteriorFrame) lsmInitialState.getRTreeInteriorFrameFactory().createFrame(), (IRTreeLeafFrame) lsmInitialState.getRTreeLeafFrameFactory().createFrame());
        } else {
            rtreeCursors[i].reset();
        }
        if (rtreeAccessors[i] == null) {
            rtreeAccessors[i] = (RTreeAccessor) rtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            btreeAccessors[i] = (BTreeAccessor) btree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        } else {
            rtreeAccessors[i].reset(rtree, NoOpOperationCallback.INSTANCE);
            btreeAccessors[i].reset(btree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        }
    }
    rtreeSearchPredicate = (SearchPredicate) searchPred;
    btreeRangePredicate.setHighKey(null);
    btreeRangePredicate.setLowKey(null);
    open = true;
}
Also used : IRTreeLeafFrame(org.apache.hyracks.storage.am.rtree.api.IRTreeLeafFrame) BTreeRangeSearchCursor(org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor) IRTreeInteriorFrame(org.apache.hyracks.storage.am.rtree.api.IRTreeInteriorFrame) IBTreeLeafFrame(org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree) RTreeSearchCursor(org.apache.hyracks.storage.am.rtree.impls.RTreeSearchCursor) BloomFilterAwareBTreePointSearchCursor(org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)

Example 3 with BloomFilterAwareBTreePointSearchCursor

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

the class LSMInvertedIndexRangeSearchCursor method open.

@Override
public void open(ICursorInitialState initState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMInvertedIndexRangeSearchCursorInitialState lsmInitState = (LSMInvertedIndexRangeSearchCursorInitialState) initState;
    cmp = lsmInitState.getOriginalKeyComparator();
    int numComponents = lsmInitState.getNumComponents();
    rangeCursors = new IIndexCursor[numComponents];
    for (int i = 0; i < numComponents; i++) {
        IInvertedIndexAccessor invIndexAccessor = (IInvertedIndexAccessor) lsmInitState.getIndexAccessors().get(i);
        rangeCursors[i] = invIndexAccessor.createRangeSearchCursor();
        invIndexAccessor.rangeSearch(rangeCursors[i], lsmInitState.getSearchPredicate());
    }
    lsmHarness = lsmInitState.getLSMHarness();
    operationalComponents = lsmInitState.getOperationalComponents();
    includeMutableComponent = lsmInitState.getIncludeMemComponent();
    // For searching the deleted-keys BTrees.
    this.keysOnlyTuple = lsmInitState.getKeysOnlyTuple();
    deletedKeysBTreeAccessors = lsmInitState.getDeletedKeysBTreeAccessors();
    if (!deletedKeysBTreeAccessors.isEmpty()) {
        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(keysOnlyTuple, keysOnlyTuple, true, true, keyCmp, keyCmp);
    setPriorityQueueComparator();
    initPriorityQueue();
}
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) IInvertedIndexAccessor(org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedIndexAccessor) BloomFilterAwareBTreePointSearchCursor(org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)

Example 4 with BloomFilterAwareBTreePointSearchCursor

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

the class LSMBTreePointSearchCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMBTreeCursorInitialState lsmInitialState = (LSMBTreeCursorInitialState) initialState;
    operationalComponents = lsmInitialState.getOperationalComponents();
    lsmHarness = lsmInitialState.getLSMHarness();
    searchCallback = lsmInitialState.getSearchOperationCallback();
    predicate = (RangePredicate) lsmInitialState.getSearchPredicate();
    numBTrees = operationalComponents.size();
    if (rangeCursors == null || rangeCursors.length != numBTrees) {
        // object creation: should be relatively low
        rangeCursors = new BTreeRangeSearchCursor[numBTrees];
        btreeAccessors = new BTreeAccessor[numBTrees];
    }
    includeMutableComponent = false;
    for (int i = 0; i < numBTrees; i++) {
        ILSMComponent component = operationalComponents.get(i);
        BTree btree;
        if (component.getType() == LSMComponentType.MEMORY) {
            includeMutableComponent = true;
            // No need for a bloom filter for the in-memory BTree.
            if (rangeCursors[i] == null || rangeCursors[i].isBloomFilterAware()) {
                // create a new one
                IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) lsmInitialState.getLeafFrameFactory().createFrame();
                rangeCursors[i] = new BTreeRangeSearchCursor(leafFrame, false);
            } else {
                // reset
                rangeCursors[i].reset();
            }
            btree = ((LSMBTreeMemoryComponent) component).getBTree();
        } else {
            if (rangeCursors[i] != null && rangeCursors[i].isBloomFilterAware()) {
                // can re-use cursor
                ((BloomFilterAwareBTreePointSearchCursor) rangeCursors[i]).resetBloomFilter(((LSMBTreeDiskComponent) component).getBloomFilter());
                rangeCursors[i].reset();
            } else {
                // create new cursor <should be relatively rare>
                IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) lsmInitialState.getLeafFrameFactory().createFrame();
                rangeCursors[i] = new BloomFilterAwareBTreePointSearchCursor(leafFrame, false, ((LSMBTreeDiskComponent) component).getBloomFilter());
            }
            btree = ((LSMBTreeDiskComponent) component).getBTree();
        }
        if (btreeAccessors[i] == null) {
            btreeAccessors[i] = (BTreeAccessor) btree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        } else {
            // re-use
            btreeAccessors[i].reset(btree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        }
    }
    nextHasBeenCalled = false;
    foundTuple = false;
}
Also used : BTreeRangeSearchCursor(org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor) IBTreeLeafFrame(org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) BloomFilterAwareBTreePointSearchCursor(org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)

Example 5 with BloomFilterAwareBTreePointSearchCursor

use of org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor 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)

Aggregations

IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)5 ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)5 BloomFilterAwareBTreePointSearchCursor (org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)5 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)3 BTreeRangeSearchCursor (org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor)3 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)2 MultiComparator (org.apache.hyracks.storage.common.MultiComparator)2 IInvertedIndexAccessor (org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedIndexAccessor)1 IRTreeInteriorFrame (org.apache.hyracks.storage.am.rtree.api.IRTreeInteriorFrame)1 IRTreeLeafFrame (org.apache.hyracks.storage.am.rtree.api.IRTreeLeafFrame)1 RTree (org.apache.hyracks.storage.am.rtree.impls.RTree)1 RTreeSearchCursor (org.apache.hyracks.storage.am.rtree.impls.RTreeSearchCursor)1