Search in sources :

Example 1 with BTreeRangeSearchCursor

use of org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor in project asterixdb by apache.

the class LSMBuddyBTreeMergeCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMBTreeWithBuddyCursorInitialState lsmInitialState = (LSMBTreeWithBuddyCursorInitialState) initialState;
    cmp = lsmInitialState.getBuddyBTreeCmp();
    operationalComponents = lsmInitialState.getOperationalComponents();
    // We intentionally set the lsmHarness to null so that we don't call
    // lsmHarness.endSearch() because we already do that when we merge
    // actual index.
    lsmHarness = null;
    int numBTrees = operationalComponents.size();
    rangeCursors = new IIndexCursor[numBTrees];
    RangePredicate btreePredicate = new RangePredicate(null, null, true, true, cmp, cmp);
    IIndexAccessor[] btreeAccessors = new ITreeIndexAccessor[numBTrees];
    for (int i = 0; i < numBTrees; i++) {
        ILSMComponent component = operationalComponents.get(i);
        IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) lsmInitialState.getBuddyBTreeLeafFrameFactory().createFrame();
        rangeCursors[i] = new BTreeRangeSearchCursor(leafFrame, false);
        BTree buddyBtree = ((LSMBTreeWithBuddyDiskComponent) component).getBuddyBTree();
        btreeAccessors[i] = buddyBtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        btreeAccessors[i].search(rangeCursors[i], btreePredicate);
    }
    setPriorityQueueComparator();
    initPriorityQueue();
}
Also used : RangePredicate(org.apache.hyracks.storage.am.btree.impls.RangePredicate) 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) ITreeIndexAccessor(org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor) IIndexAccessor(org.apache.hyracks.storage.common.IIndexAccessor)

Example 2 with BTreeRangeSearchCursor

use of org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor in project asterixdb by apache.

the class LSMBTreeRangeSearchCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMBTreeCursorInitialState lsmInitialState = (LSMBTreeCursorInitialState) initialState;
    cmp = lsmInitialState.getOriginalKeyComparator();
    operationalComponents = lsmInitialState.getOperationalComponents();
    lsmHarness = lsmInitialState.getLSMHarness();
    searchCallback = lsmInitialState.getSearchOperationCallback();
    predicate = (RangePredicate) lsmInitialState.getSearchPredicate();
    reusablePred.setLowKeyComparator(cmp);
    reusablePred.setHighKey(predicate.getHighKey(), predicate.isHighKeyInclusive());
    reusablePred.setHighKeyComparator(predicate.getHighKeyComparator());
    includeMutableComponent = false;
    int numBTrees = operationalComponents.size();
    if (rangeCursors == null || rangeCursors.length != numBTrees) {
        // object creation: should be relatively low
        rangeCursors = new IIndexCursor[numBTrees];
        btreeAccessors = new BTreeAccessor[numBTrees];
    }
    for (int i = 0; i < numBTrees; i++) {
        ILSMComponent component = operationalComponents.get(i);
        BTree btree;
        if (rangeCursors[i] == null) {
            // create, should be relatively rare
            IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) lsmInitialState.getLeafFrameFactory().createFrame();
            rangeCursors[i] = new BTreeRangeSearchCursor(leafFrame, false);
        } else {
            // re-use
            rangeCursors[i].reset();
        }
        if (component.getType() == LSMComponentType.MEMORY) {
            includeMutableComponent = true;
            btree = ((LSMBTreeMemoryComponent) component).getBTree();
        } else {
            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);
        }
        btreeAccessors[i].search(rangeCursors[i], searchPred);
    }
    setPriorityQueueComparator();
    initPriorityQueue();
    canCallProceed = 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)

Example 3 with BTreeRangeSearchCursor

use of org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor 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 4 with BTreeRangeSearchCursor

use of org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor in project asterixdb by apache.

the class LSMRTreeWithAntiMatterTuplesSearchCursor method open.

@Override
public void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException {
    LSMRTreeCursorInitialState lsmInitialState = (LSMRTreeCursorInitialState) initialState;
    cmp = lsmInitialState.getHilbertCmp();
    btreeCmp = lsmInitialState.getBTreeCmp();
    lsmHarness = lsmInitialState.getLSMHarness();
    comparatorFields = lsmInitialState.getComparatorFields();
    operationalComponents = lsmInitialState.getOperationalComponents();
    rtreeSearchPredicate = (SearchPredicate) searchPred;
    searchCallback = lsmInitialState.getSearchOperationCallback();
    includeMutableComponent = false;
    numMutableComponents = 0;
    int numImmutableComponents = 0;
    for (ILSMComponent component : operationalComponents) {
        if (component.getType() == LSMComponentType.MEMORY) {
            includeMutableComponent = true;
            numMutableComponents++;
        } else {
            numImmutableComponents++;
        }
    }
    if (includeMutableComponent) {
        btreeRangePredicate = new RangePredicate(null, null, true, true, btreeCmp, btreeCmp);
    }
    mutableRTreeCursors = new RTreeSearchCursor[numMutableComponents];
    mutableRTreeAccessors = new ITreeIndexAccessor[numMutableComponents];
    btreeCursors = new BTreeRangeSearchCursor[numMutableComponents];
    btreeAccessors = new ITreeIndexAccessor[numMutableComponents];
    for (int i = 0; i < numMutableComponents; i++) {
        ILSMComponent component = operationalComponents.get(i);
        RTree rtree = ((LSMRTreeMemoryComponent) component).getRTree();
        BTree btree = ((LSMRTreeMemoryComponent) component).getBTree();
        mutableRTreeCursors[i] = new RTreeSearchCursor((IRTreeInteriorFrame) lsmInitialState.getRTreeInteriorFrameFactory().createFrame(), (IRTreeLeafFrame) lsmInitialState.getRTreeLeafFrameFactory().createFrame());
        btreeCursors[i] = new BTreeRangeSearchCursor((IBTreeLeafFrame) lsmInitialState.getBTreeLeafFrameFactory().createFrame(), false);
        btreeAccessors[i] = btree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        mutableRTreeAccessors[i] = rtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
    }
    rangeCursors = new RTreeSearchCursor[numImmutableComponents];
    ITreeIndexAccessor[] immutableRTreeAccessors = new ITreeIndexAccessor[numImmutableComponents];
    int j = 0;
    for (int i = numMutableComponents; i < operationalComponents.size(); i++) {
        ILSMComponent component = operationalComponents.get(i);
        rangeCursors[j] = new RTreeSearchCursor((IRTreeInteriorFrame) lsmInitialState.getRTreeInteriorFrameFactory().createFrame(), (IRTreeLeafFrame) lsmInitialState.getRTreeLeafFrameFactory().createFrame());
        RTree rtree = ((LSMRTreeDiskComponent) component).getRTree();
        immutableRTreeAccessors[j] = rtree.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        immutableRTreeAccessors[j].search(rangeCursors[j], searchPred);
        j++;
    }
    searchNextCursor();
    setPriorityQueueComparator();
    initPriorityQueue();
    open = true;
}
Also used : RangePredicate(org.apache.hyracks.storage.am.btree.impls.RangePredicate) IRTreeLeafFrame(org.apache.hyracks.storage.am.rtree.api.IRTreeLeafFrame) BTreeRangeSearchCursor(org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) RTreeSearchCursor(org.apache.hyracks.storage.am.rtree.impls.RTreeSearchCursor) ITreeIndexAccessor(org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor) 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) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree)

Example 5 with BTreeRangeSearchCursor

use of org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor 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)

Aggregations

BTreeRangeSearchCursor (org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor)11 IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)8 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)8 ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)7 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)6 ITreeIndexAccessor (org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor)6 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)3 BloomFilterAwareBTreePointSearchCursor (org.apache.hyracks.storage.am.lsm.common.impls.BloomFilterAwareBTreePointSearchCursor)3 RTreeSearchCursor (org.apache.hyracks.storage.am.rtree.impls.RTreeSearchCursor)3 ArrayList (java.util.ArrayList)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)2 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)2 IRTreeInteriorFrame (org.apache.hyracks.storage.am.rtree.api.IRTreeInteriorFrame)2 IRTreeLeafFrame (org.apache.hyracks.storage.am.rtree.api.IRTreeLeafFrame)2 RTree (org.apache.hyracks.storage.am.rtree.impls.RTree)2 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInput (java.io.DataInput)1 DataInputStream (java.io.DataInputStream)1 Random (java.util.Random)1