You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2019/02/26 12:17:33 UTC
[ignite] 02/11: nextRow field
This is an automated email from the ASF dual-hosted git repository.
sboikov pushed a commit to branch ignite-invokeAll
in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 6d8f53b31dbef26636da42804cfb6e0cfe1c2787
Author: Sergi Vladykin <se...@gmail.com>
AuthorDate: Fri Feb 22 21:26:33 2019 +0300
nextRow field
---
.../cache/persistence/tree/BPlusTree.java | 44 +++++++++++++++++-----
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java
index a02df7d..f911280 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java
@@ -2895,6 +2895,9 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
*/
boolean gettingHigh;
+ /** Used in batch operations like {@link InvokeAll}. */
+ L nextRow;
+
/**
* @param row Row.
* @param findLast find last row.
@@ -2908,6 +2911,18 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.findLast = findLast;
}
+ /**
+ * @param sortedRows Sorted rows.
+ */
+ final void takeNextRow(Iterator<? extends L> sortedRows) {
+ if (sortedRows.hasNext()) {
+ nextRow = sortedRows.next();
+ assert nextRow != null;
+ }
+ else
+ nextRow = null;
+ }
+
@SuppressWarnings({"unchecked", "WrapperTypeMayBePrimitive"})
protected final T convertOldRow(boolean needOld, T oldRow) {
if (needOld)
@@ -2952,10 +2967,14 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
* @param sortedRows Sorted rows.
* @return {@code true} If was successfully switched to the next row.
*/
- protected final boolean doNextRow(Result res, Iterator<? extends L> sortedRows) {
- if (res.retry || !isFinished() || !sortedRows.hasNext())
+ protected final boolean doSwitchToNextRow(Result res, Iterator<? extends L> sortedRows) {
+ if (nextRow == null || res.retry || !isFinished())
return false;
+ // Switch to the next row.
+ row = nextRow;
+ takeNextRow(sortedRows);
+
// Well need to get high enough to start new search.
assert !gettingHigh;
gettingHigh = true;
@@ -2963,9 +2982,6 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
// Reinitialize state to continue working with the next row.
lockRetriesCnt = getLockRetries();
- row = sortedRows.next();
- assert row != null;
-
return true;
}
@@ -3002,7 +3018,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
* @param cnt Row count.
* @return Insertion point.
*/
- private int findInsertionPointGettingHigh(int lvl, BPlusIO<L> io, long pageAddr, int cnt) throws IgniteCheckedException {
+ protected final int findInsertionPointGettingHigh(int lvl, BPlusIO<L> io, long pageAddr, int cnt) throws IgniteCheckedException {
int idx;
if (cnt == 0)
@@ -3224,11 +3240,13 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.sortedRows = sortedRows;
foundRows = new ArrayList<>();
+
+ takeNextRow(sortedRows);
}
/** {@inheritDoc} */
@Override boolean switchToNextRow(Result res) {
- if (!doNextRow(res, sortedRows))
+ if (!doSwitchToNextRow(res, sortedRows))
return false;
// Reset state.
@@ -3656,11 +3674,13 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.sortedRows = sortedRows;
oldRows = new ArrayList<>();
+
+ takeNextRow(sortedRows);
}
/** {@inheritDoc} */
@Override boolean switchToNextRow(Result res) {
- if (!doNextRow(res, sortedRows))
+ if (!doSwitchToNextRow(res, sortedRows))
return false;
// Reset state.
@@ -4051,11 +4071,13 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.sortedRows = sortedRows;
this.closures = closures;
+
+ takeNextRow(sortedRows);
}
/** {@inheritDoc} */
@Override boolean switchToNextRow(Result res) throws IgniteCheckedException {
- if (!doNextRow(res, sortedRows))
+ if (!doSwitchToNextRow(res, sortedRows))
return false;
reuseFreePagesFromBag(reuseBag, 15);
@@ -4404,11 +4426,13 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.sortedRows = sortedRows;
removedRows = new ArrayList<>();
+
+ takeNextRow(sortedRows);
}
/** {@inheritDoc} */
@Override boolean switchToNextRow(Result res) throws IgniteCheckedException {
- if (!doNextRow(res, sortedRows))
+ if (!doSwitchToNextRow(res, sortedRows))
return false;
reuseFreePagesFromBag(reuseBag, 15);