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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations