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 2017/04/06 11:10:19 UTC
[1/2] ignite git commit: tmp
Repository: ignite
Updated Branches:
refs/heads/ignite-4811-no-start-ver 30f5fc115 -> 112695b61
tmp
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b30d9897
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b30d9897
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b30d9897
Branch: refs/heads/ignite-4811-no-start-ver
Commit: b30d9897ab859dede111832e7448003b85ac1346
Parents: 30f5fc1
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 6 13:09:07 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 6 13:09:07 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMapEntry.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b30d9897/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index abfc06b..846c633 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -141,7 +141,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/** Start version. */
@GridToStringInclude
- protected long startVer;
+ protected final long startVer;
/** Version. */
@GridToStringInclude
@@ -188,15 +188,15 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
this.hash = hash;
this.cctx = cctx;
- this.val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
+ val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
-// synchronized (this) {
-// value(val);
-// }
+ synchronized (this) {
+ value(val);
+ }
+
+ ver = cctx.versions().next();
-// ver = cctx.versions().next();
-//
-// startVer = ver.order();
+ startVer = ver.order();
}
/** {@inheritDoc} */
@@ -294,7 +294,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
* @return {@code True} if start version.
*/
public boolean isStartVersion() {
- return ver == null;//ver.nodeOrder() == cctx.localNode().order() && ver.order() == startVer;
+ return ver.nodeOrder() == cctx.localNode().order() && ver.order() == startVer;
}
/** {@inheritDoc} */
[2/2] ignite git commit: tmp
Posted by sb...@apache.org.
tmp
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/112695b6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/112695b6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/112695b6
Branch: refs/heads/ignite-4811-no-start-ver
Commit: 112695b618b753d6ef1af88ffc64fe4d42aa7d23
Parents: b30d989
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 6 14:10:10 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 6 14:10:10 2017 +0300
----------------------------------------------------------------------
.../cache/IgniteCacheOffheapManagerImpl.java | 30 +++++++++-----
.../cache/database/CacheDataRowAdapter.java | 4 ++
.../cache/database/MetadataStorage.java | 3 +-
.../cache/database/tree/BPlusTree.java | 43 ++++++++++++--------
.../processors/database/BPlusTreeSelfTest.java | 3 +-
.../processors/query/h2/database/H2Tree.java | 3 +-
6 files changed, 56 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/112695b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index a1aea2f..6621aca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -1326,7 +1326,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
* @param link Link.
* @param rowData Required row data.
*/
- DataRow(int hash, long link, CacheDataRowAdapter.RowData rowData) {
+ DataRow(int hash, long link, CacheDataRowAdapter.RowData rowData, long addr) {
super(link);
this.hash = hash;
@@ -1335,7 +1335,11 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
try {
// We can not init data row lazily because underlying buffer can be concurrently cleared.
- initFromLink(cctx, rowData);
+ if (addr == 0L)
+ initFromLink(cctx, rowData);
+ else {
+ initFromLink(addr, cctx, rowData);
+ }
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
@@ -1422,7 +1426,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
}
/** {@inheritDoc} */
- @Override protected int compare(BPlusIO<CacheSearchRow> io, long pageAddr, int idx, CacheSearchRow row)
+ @Override protected int compare(BPlusIO<CacheSearchRow> io, long pageAddr, int idx, CacheSearchRow row, IgniteInClosure c)
throws IgniteCheckedException {
int hash = ((RowLinkIO)io).getHash(pageAddr, idx);
@@ -1435,7 +1439,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
assert row.key() != null : row;
- return compareKeys(row.key(), link);
+ return compareKeys(row.key(), link, hash, c);
}
/** {@inheritDoc} */
@@ -1448,7 +1452,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
(CacheDataRowAdapter.RowData)flags :
CacheDataRowAdapter.RowData.FULL;
- return rowStore.dataRow(hash, link, x);
+ return rowStore.dataRow(hash, link, null, 0);
}
/**
@@ -1457,7 +1461,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
* @return Compare result.
* @throws IgniteCheckedException If failed.
*/
- private int compareKeys(KeyCacheObject key, final long link) throws IgniteCheckedException {
+ private int compareKeys(KeyCacheObject key, final long link, int hash, IgniteInClosure c) throws IgniteCheckedException {
byte[] bytes = key.valueBytes(cctx.cacheObjectContext());
final long pageId = pageId(link);
@@ -1508,6 +1512,12 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
return b1 > b2 ? 1 : -1;
}
+ if (c != null) {
+ CacheDataRowAdapter.RowData x = CacheDataRowAdapter.RowData.NO_KEY;
+
+ c.apply(rowStore.dataRow(hash, link, x, pageAddr + data.offset()));
+ }
+
return 0;
}
}
@@ -1576,7 +1586,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
* @return Search row.
*/
private CacheSearchRow keySearchRow(int hash, long link) {
- return new DataRow(hash, link, CacheDataRowAdapter.RowData.KEY_ONLY);
+ return new DataRow(hash, link, CacheDataRowAdapter.RowData.KEY_ONLY, 0);
}
/**
@@ -1585,8 +1595,8 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
* @param rowData Required row data.
* @return Data row.
*/
- private CacheDataRow dataRow(int hash, long link, CacheDataRowAdapter.RowData rowData) {
- return new DataRow(hash, link, rowData);
+ private CacheDataRow dataRow(int hash, long link, CacheDataRowAdapter.RowData rowData, long addr) {
+ return new DataRow(hash, link, rowData, addr);
}
}
@@ -1821,7 +1831,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
}
/** {@inheritDoc} */
- @Override protected int compare(BPlusIO<PendingRow> io, long pageAddr, int idx, PendingRow row)
+ @Override protected int compare(BPlusIO<PendingRow> io, long pageAddr, int idx, PendingRow row, IgniteInClosure c)
throws IgniteCheckedException {
long expireTime = ((PendingRowIO)io).getExpireTime(pageAddr, idx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/112695b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
index eca59d6..9647fe02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
@@ -84,6 +84,10 @@ public class CacheDataRowAdapter implements CacheDataRow {
this.expireTime = expireTime;
}
+ public final void initFromLink(long addr, GridCacheContext<?, ?> cctx, RowData rowData) throws IgniteCheckedException {
+ readFullRow(cctx.cacheObjectContext(), addr, rowData);
+ }
+
/**
* Read row from data pages.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/112695b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
index ca4ad05..a9fe0a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
import org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
/**
* Metadata storage.
@@ -191,7 +192,7 @@ public class MetadataStorage implements MetaStore {
/** {@inheritDoc} */
@Override protected int compare(final BPlusIO<IndexItem> io, final long pageAddr, final int idx,
- final IndexItem row) throws IgniteCheckedException {
+ final IndexItem row, IgniteInClosure c) throws IgniteCheckedException {
final int off = ((IndexIO)io).getOffset(pageAddr, idx);
int shift = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/112695b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
index 7be8297..c13a68b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
@@ -254,7 +254,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
g.backId(0L); // Usually we'll go left down and don't need it.
int cnt = io.getCount(pageAddr);
- int idx = findInsertionPoint(io, pageAddr, 0, cnt, g.row, g.shift);
+ int idx = findInsertionPoint(io, pageAddr, 0, cnt, g.row, g.shift, g);
boolean found = idx >= 0;
@@ -335,7 +335,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
assert p.btmLvl == 0 : "split is impossible with replace";
final int cnt = io.getCount(pageAddr);
- final int idx = findInsertionPoint(io, pageAddr, 0, cnt, p.row, 0);
+ final int idx = findInsertionPoint(io, pageAddr, 0, cnt, p.row, 0, null);
if (idx < 0) // Not found, split or merge happened.
return RETRY;
@@ -396,7 +396,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
return RETRY;
int cnt = io.getCount(pageAddr);
- int idx = findInsertionPoint(io, pageAddr, 0, cnt, p.row, 0);
+ int idx = findInsertionPoint(io, pageAddr, 0, cnt, p.row, 0, null);
if (idx >= 0) // We do not support concurrent put of the same key.
throw new IllegalStateException("Duplicate row in index.");
@@ -444,7 +444,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
assert cnt <= Short.MAX_VALUE: cnt;
- int idx = findInsertionPoint(io, leafAddr, 0, cnt, r.row, 0);
+ int idx = findInsertionPoint(io, leafAddr, 0, cnt, r.row, 0, null);
if (idx < 0)
return RETRY; // We've found exact match on search but now it's gone.
@@ -1142,7 +1142,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
if (io.isLeaf()) {
for (int i = 0; i < cnt; i++) {
- if (minRow != null && compare(io, pageAddr, i, minRow) <= 0)
+ if (minRow != null && compare(io, pageAddr, i, minRow, null) <= 0)
fail("Wrong sort order: " + U.hexLong(pageId) + " , at " + i + " , minRow: " + minRow);
minRow = io.getLookupRow(this, pageAddr, i);
@@ -1155,14 +1155,14 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
for (int i = 0; i < cnt; i++) {
L row = io.getLookupRow(this, pageAddr, i);
- if (minRow != null && compare(io, pageAddr, i, minRow) <= 0)
+ if (minRow != null && compare(io, pageAddr, i, minRow, null) <= 0)
fail("Min row violated: " + row + " , minRow: " + minRow);
long leftId = inner(io).getLeft(pageAddr, i);
L leafRow = getGreatestRowInSubTree(leftId);
- int cmp = compare(io, pageAddr, i, leafRow);
+ int cmp = compare(io, pageAddr, i, leafRow, null);
if (cmp < 0 || (cmp != 0 && canGetRowFromInner))
fail("Wrong inner row: " + U.hexLong(pageId) + " , at: " + i + " , leaf: " + leafRow +
@@ -2213,7 +2213,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
/**
* Get operation.
*/
- private abstract class Get {
+ private abstract class Get implements IgniteInClosure {
/** */
long rmvId;
@@ -2250,6 +2250,10 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.row = row;
}
+ @Override public void apply(Object o) {
+
+ }
+
/**
* @param g Other operation to copy from.
* @return {@code this}.
@@ -2790,6 +2794,10 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
this.x = x;
}
+ @Override public void apply(Object o) {
+ foundRow = (T)o;
+ }
+
/** {@inheritDoc} */
@Override void pageId(long pageId) {
this.pageId = pageId;
@@ -2832,7 +2840,8 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
if (closureInvoked == FALSE) {
closureInvoked = READY;
- foundRow = getRow(io, pageAddr, idx, x);
+ if (foundRow == null)
+ foundRow = getRow(io, pageAddr, idx, x);
}
return true;
@@ -3549,7 +3558,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
assert tail.type == Tail.EXACT: tail.type;
if (tail.idx == Short.MIN_VALUE) {
- int idx = findInsertionPoint(tail.io, tail.buf, 0, tail.getCount(), row, 0);
+ int idx = findInsertionPoint(tail.io, tail.buf, 0, tail.getCount(), row, 0, null);
assert checkIndex(idx): idx;
@@ -4148,7 +4157,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
* @return Insertion point as in {@link Arrays#binarySearch(Object[], Object, Comparator)}.
* @throws IgniteCheckedException If failed.
*/
- private int findInsertionPoint(BPlusIO<L> io, long buf, int low, int cnt, L row, int shift)
+ private int findInsertionPoint(BPlusIO<L> io, long buf, int low, int cnt, L row, int shift, IgniteInClosure c)
throws IgniteCheckedException {
assert row != null;
@@ -4157,7 +4166,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
while (low <= high) {
int mid = (low + high) >>> 1;
- int cmp = compare(io, buf, mid, row);
+ int cmp = compare(io, buf, mid, row, c);
if (cmp == 0)
cmp = -shift; // We need to fix the case when search row matches multiple data rows.
@@ -4225,7 +4234,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
* @return Comparison result as in {@link Comparator#compare(Object, Object)}.
* @throws IgniteCheckedException If failed.
*/
- protected abstract int compare(BPlusIO<L> io, long pageAddr, int idx, L row) throws IgniteCheckedException;
+ protected abstract int compare(BPlusIO<L> io, long pageAddr, int idx, L row, IgniteInClosure c) throws IgniteCheckedException;
/**
* Get a full detached data row.
@@ -4321,10 +4330,10 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
*/
private int findLowerBound(long pageAddr, BPlusIO<L> io, int cnt) throws IgniteCheckedException {
// Compare with the first row on the page.
- int cmp = compare(io, pageAddr, 0, lowerBound);
+ int cmp = compare(io, pageAddr, 0, lowerBound, null);
if (cmp < 0 || (cmp == 0 && lowerShift == 1)) {
- int idx = findInsertionPoint(io, pageAddr, 0, cnt, lowerBound, lowerShift);
+ int idx = findInsertionPoint(io, pageAddr, 0, cnt, lowerBound, lowerShift, null);
assert idx < 0;
@@ -4344,10 +4353,10 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
*/
private int findUpperBound(long pageAddr, BPlusIO<L> io, int low, int cnt) throws IgniteCheckedException {
// Compare with the last row on the page.
- int cmp = compare(io, pageAddr, cnt - 1, upperBound);
+ int cmp = compare(io, pageAddr, cnt - 1, upperBound, null);
if (cmp > 0) {
- int idx = findInsertionPoint(io, pageAddr, low, cnt, upperBound, 1);
+ int idx = findInsertionPoint(io, pageAddr, low, cnt, upperBound, 1, null);
assert idx < 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/112695b6/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
index 4c6fe4c..dad5aa4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
@@ -54,6 +54,7 @@ import org.apache.ignite.internal.util.lang.GridCursor;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.Nullable;
@@ -1451,7 +1452,7 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override protected int compare(BPlusIO<Long> io, long pageAddr, int idx, Long n2)
+ @Override protected int compare(BPlusIO<Long> io, long pageAddr, int idx, Long n2, IgniteInClosure c)
throws IgniteCheckedException {
Long n1 = io.getLookupRow(this, pageAddr, idx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/112695b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
index f673717..b8cf611 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasInnerI
import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasLeafIO;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
import org.h2.result.SearchRow;
import org.h2.table.IndexColumn;
import org.h2.value.Value;
@@ -159,7 +160,7 @@ public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row> {
/** {@inheritDoc} */
@Override protected int compare(BPlusIO<SearchRow> io, long pageAddr, int idx,
- SearchRow row) throws IgniteCheckedException {
+ SearchRow row, IgniteInClosure c1) throws IgniteCheckedException {
if (inlineSize() == 0)
return compareRows(getRow(io, pageAddr, idx), row);
else {