Taewoo Kim has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/2623
Change subject: [ASTERIXDB-2374][RT] Index-only plan on B+Tree disk components
......................................................................
[ASTERIXDB-2374][RT] Index-only plan on B+Tree disk components
- user model changes: no
- storage format changes: no
- interface changes: no
Details: Let the index-only plan properly work on the disk components of B+Tree.
Currently, only the records from in-memory components has been applied because
searchCallback.proceed() is only called for those.
Change-Id: I655eacc5517352a382d1b61f7b630f0f307b7c7b
---
M
hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
M
hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java
2 files changed, 43 insertions(+), 41 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/23/2623/1
diff --git
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
index a675047..6eef5a9 100644
---
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
+++
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
@@ -105,48 +105,50 @@
while (!outputPriorityQueue.isEmpty() || needPushElementIntoQueue) {
if (!outputPriorityQueue.isEmpty()) {
PriorityQueueElement queueHead = outputPriorityQueue.peek();
- if (canCallProceed && includeMutableComponent) {
+ if (canCallProceed) {
resultOfSearchCallbackProceed =
searchCallback.proceed(queueHead.getTuple());
- if (!resultOfSearchCallbackProceed) {
- // In case proceed() fails and there is an in-memory
component,
- // we can't simply use this element since there might
be a change.
- PriorityQueueElement mutableElement =
remove(outputPriorityQueue, 0);
- if (mutableElement != null) {
- // Copies the current queue head
- if (tupleBuilder == null) {
- tupleBuilder = new
ArrayTupleBuilder(cmp.getKeyFieldCount());
+ if (includeMutableComponent) {
+ if (!resultOfSearchCallbackProceed) {
+ // In case proceed() fails and there is an
in-memory component,
+ // we can't simply use this element since there
might be a change.
+ PriorityQueueElement mutableElement =
remove(outputPriorityQueue, 0);
+ if (mutableElement != null) {
+ // Copies the current queue head
+ if (tupleBuilder == null) {
+ tupleBuilder = new
ArrayTupleBuilder(cmp.getKeyFieldCount());
+ }
+ TupleUtils.copyTuple(tupleBuilder,
queueHead.getTuple(), cmp.getKeyFieldCount());
+
copyTuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
+ // Unlatches/unpins the leaf page of the index.
+ rangeCursors[0].close();
+ // Reconcile.
+ searchCallback.reconcile(copyTuple);
+ // Re-traverses the index.
+ reusablePred.setLowKey(copyTuple, true);
+ btreeAccessors[0].search(rangeCursors[0],
reusablePred);
+
pushIntoQueueFromCursorAndReplaceThisElement(mutableElement);
+ // now that we have completed the search and
we have latches over the pages,
+ // it is safe to complete the operation.. but
as per the API of the callback
+ // we only complete if we're producing this
tuple
+ // get head again
+ queueHead = outputPriorityQueue.peek();
+ /*
+ * We need to restart in one of two cases:
+ * 1. no more elements in the priority queue.
+ * 2. the key of the head has changed (which
means we need to call proceed)
+ */
+ if (queueHead == null ||
cmp.compare(copyTuple, queueHead.getTuple()) != 0) {
+ // cancel since we're not continuing
+ searchCallback.cancel(copyTuple);
+ continue;
+ }
+ searchCallback.complete(copyTuple);
+ // it is safe to proceed now
+ } else {
+ // There are no more elements in the memory
component.. can safely skip locking for the
+ // remaining operations
+ includeMutableComponent = false;
}
- TupleUtils.copyTuple(tupleBuilder,
queueHead.getTuple(), cmp.getKeyFieldCount());
- copyTuple.reset(tupleBuilder.getFieldEndOffsets(),
tupleBuilder.getByteArray());
- // Unlatches/unpins the leaf page of the index.
- rangeCursors[0].close();
- // Reconcile.
- searchCallback.reconcile(copyTuple);
- // Re-traverses the index.
- reusablePred.setLowKey(copyTuple, true);
- btreeAccessors[0].search(rangeCursors[0],
reusablePred);
-
pushIntoQueueFromCursorAndReplaceThisElement(mutableElement);
- // now that we have completed the search and we
have latches over the pages,
- // it is safe to complete the operation.. but as
per the API of the callback
- // we only complete if we're producing this tuple
- // get head again
- queueHead = outputPriorityQueue.peek();
- /*
- * We need to restart in one of two cases:
- * 1. no more elements in the priority queue.
- * 2. the key of the head has changed (which means
we need to call proceed)
- */
- if (queueHead == null || cmp.compare(copyTuple,
queueHead.getTuple()) != 0) {
- // cancel since we're not continuing
- searchCallback.cancel(copyTuple);
- continue;
- }
- searchCallback.complete(copyTuple);
- // it is safe to proceed now
- } else {
- // There are no more elements in the memory
component.. can safely skip locking for the
- // remaining operations
- includeMutableComponent = false;
}
}
}
diff --git
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java
index baf0d4a..efacad1 100644
---
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java
+++
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java
@@ -107,6 +107,6 @@
@Override
public boolean getSearchOperationCallbackProceedResult() {
- return false;
+ return currentCursor.getSearchOperationCallbackProceedResult();
}
}
--
To view, visit https://asterix-gerrit.ics.uci.edu/2623
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I655eacc5517352a382d1b61f7b630f0f307b7c7b
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <[email protected]>