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 2016/04/19 14:58:39 UTC
[22/50] [abbrv] ignite git commit: ignite-db - get rid of DataStore
ignite-db - get rid of DataStore
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e895804d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e895804d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e895804d
Branch: refs/heads/ignite-db-x-10884
Commit: e895804ddf88d2b0aab15586a58dea86164def50
Parents: 0ce9254
Author: S.Vladykin <sv...@gridgain.com>
Authored: Tue Apr 12 22:29:37 2016 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Tue Apr 12 22:29:37 2016 +0300
----------------------------------------------------------------------
.../cache/database/tree/BPlusTree.java | 36 +++++++-------------
.../cache/database/tree/DataStore.java | 36 --------------------
.../cache/database/tree/io/BPlusIO.java | 5 +--
.../database/IgniteCacheH2DatabaseManager.java | 4 +--
.../processors/query/h2/IgniteH2Indexing.java | 4 +--
.../query/h2/database/BPlusTreeIndex.java | 24 +++++++++----
.../query/h2/database/H2RowStore.java | 20 ++++++-----
.../processors/query/h2/opt/GridH2Table.java | 15 ++++----
.../query/h2/opt/GridH2TableSelfTest.java | 2 +-
9 files changed, 57 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/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 c45fc39..9a4dab5 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
@@ -72,9 +72,6 @@ public abstract class BPlusTree<L, T extends L> {
private final AtomicLong globalRmvId = new AtomicLong(U.currentTimeMillis() * 1000_000); // TODO init from WAL?
/** */
- private final DataStore<T> dataStore;
-
- /** */
private final GridTreePrinter<Long> treePrinter = new GridTreePrinter<Long>() {
/** */
private boolean keys = true;
@@ -459,20 +456,11 @@ public abstract class BPlusTree<L, T extends L> {
};
/**
- * @param dataStore Data store.
* @param metaPageId Meta page ID.
* @param initNew Initialize new index.
* @throws IgniteCheckedException If failed.
*/
- public BPlusTree(
- DataStore<T> dataStore,
- FullPageId metaPageId,
- boolean initNew
- ) throws IgniteCheckedException {
- assert dataStore != null;
-
- this.dataStore = dataStore;
-
+ public BPlusTree(FullPageId metaPageId, boolean initNew) throws IgniteCheckedException {
// TODO make configurable: 0 <= minFill <= maxFill <= 1
minFill = 0f; // Testing worst case when merge happens only on empty page.
maxFill = 0f; // Avoiding random effects on testing.
@@ -1503,17 +1491,6 @@ public abstract class BPlusTree<L, T extends L> {
}
/**
- * @param io IO.
- * @param buf Buffer.
- * @param idx Index.
- * @return Full data row.
- * @throws IgniteCheckedException If failed.
- */
- protected final T getRow(BPlusIO<L> io, ByteBuffer buf, int idx) throws IgniteCheckedException {
- return dataStore.getRow(io, buf, idx);
- }
-
- /**
* Get operation.
*/
private abstract class Get {
@@ -2245,6 +2222,17 @@ public abstract class BPlusTree<L, T extends L> {
protected abstract int compare(BPlusIO<L> io, ByteBuffer buf, int idx, L row) throws IgniteCheckedException;
/**
+ * This method can be called only if {@link BPlusIO#canGetRow()} returns {@code true}.
+ *
+ * @param io IO.
+ * @param buf Buffer.
+ * @param idx Index.
+ * @return Full data row.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected abstract T getRow(BPlusIO<L> io, ByteBuffer buf, int idx) throws IgniteCheckedException;
+
+ /**
* @param pageId Page ID.
* @return Page.
* @throws IgniteCheckedException If failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/DataStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/DataStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/DataStore.java
deleted file mode 100644
index 31c5716..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/DataStore.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.database.tree;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
-
-/**
- * Data store.
- */
-public interface DataStore<T> {
- /**
- * @param io IO.
- * @param buf Buffer.
- * @param idx Index.
- * @return Data row.
- * @throws IgniteCheckedException If failed.
- */
- public T getRow(BPlusIO<?> io, ByteBuffer buf, int idx) throws IgniteCheckedException;
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
index 63b477a..6fb5333 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.processors.cache.database.tree.io;
import java.nio.ByteBuffer;
-import org.apache.ignite.internal.processors.cache.database.tree.DataStore;
+import org.apache.ignite.internal.processors.cache.database.tree.BPlusTree;
/**
* Abstract IO routines for B+Tree pages.
@@ -144,7 +144,8 @@ public abstract class BPlusIO<L> extends PageIO {
public abstract void store(ByteBuffer dst, int dstIdx, BPlusIO<L> srcIo, ByteBuffer src, int srcIdx);
/**
- * @return {@code true} If we can get the whole row from this page using {@link DataStore}.
+ * @return {@code true} If we can get the whole row from this page using
+ * method {@link BPlusTree#getRow(BPlusIO, ByteBuffer, int)}.
* Must always be {@code true} for leaf pages.
*/
public abstract boolean canGetRow();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
index 90527e8..421ebef 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
@@ -89,9 +89,9 @@ public class IgniteCacheH2DatabaseManager extends GridCacheManagerAdapter implem
/**
* @param tbl Table.
- * @return New data store for table.
+ * @return New row store for the given table.
*/
- public H2RowStore createDataStore(GridH2Table tbl) {
+ public H2RowStore createRowStore(GridH2Table tbl) {
IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
return new H2RowStore(dbMgr.pageMemory(), tbl.rowDescriptor(), cctx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 26816e2..7d226ea 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1978,13 +1978,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/** {@inheritDoc} */
- @Override public H2RowStore createDataStore(GridH2Table tbl) {
+ @Override public H2RowStore createRowStore(GridH2Table tbl) {
int cacheId = CU.cacheId(schema.ccfg.getName());
IgniteCacheH2DatabaseManager dbMgr = databaseManager(cacheId);
if (dbMgr != null)
- return dbMgr.createDataStore(tbl);
+ return dbMgr.createRowStore(tbl);
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
index 7ea97d5..1996d83 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
@@ -26,13 +26,13 @@ import org.apache.ignite.internal.pagemem.PageIdAllocator;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.database.tree.BPlusTree;
-import org.apache.ignite.internal.processors.cache.database.tree.DataStore;
import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOInner;
import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOLeaf;
+import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
import org.apache.ignite.internal.processors.query.h2.database.io.H2InnerIO;
import org.apache.ignite.internal.processors.query.h2.database.io.H2LeafIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
+import org.apache.ignite.internal.processors.query.h2.database.io.H2RowLinkIO;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
import org.apache.ignite.internal.util.lang.GridCursor;
@@ -101,7 +101,7 @@ public class BPlusTreeIndex extends PageMemoryIndex {
initBaseIndex(tbl, 0, name, cols,
pk ? IndexType.createPrimaryKey(false, false) : IndexType.createNonUnique(false, false, false));
- tree = new H2BPlusTree(tbl.dataStore(), metaPageId, initNew);
+ tree = new H2BPlusTree(tbl.rowStore(), metaPageId, initNew);
}
/** {@inheritDoc} */
@@ -218,15 +218,22 @@ public class BPlusTreeIndex extends PageMemoryIndex {
* Specialization of {@link BPlusTree} for H2 index.
*/
private class H2BPlusTree extends BPlusTree<SearchRow, GridH2Row> {
+ /** */
+ private final H2RowStore rowStore;
+
/**
- * @param dataStore Data store.
+ * @param rowStore Row data store.
* @param metaPageId Meta page ID.
* @param initNew Initialize new index.
* @throws IgniteCheckedException If failed.
*/
- public H2BPlusTree(DataStore<GridH2Row> dataStore, FullPageId metaPageId, boolean initNew)
+ public H2BPlusTree(H2RowStore rowStore, FullPageId metaPageId, boolean initNew)
throws IgniteCheckedException {
- super(dataStore, metaPageId, initNew);
+ super(metaPageId, initNew);
+
+ assert rowStore != null;
+
+ this.rowStore = rowStore;
}
/** {@inheritDoc} */
@@ -266,5 +273,10 @@ public class BPlusTreeIndex extends PageMemoryIndex {
throws IgniteCheckedException {
return compareRows(getRow(io, buf, idx), row);
}
+
+ /** {@inheritDoc} */
+ @Override protected GridH2Row getRow(BPlusIO<SearchRow> io, ByteBuffer buf, int idx) throws IgniteCheckedException {
+ return rowStore.getRow((H2RowLinkIO)io, buf, idx);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2RowStore.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2RowStore.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2RowStore.java
index 0e18962..7697eb4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2RowStore.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2RowStore.java
@@ -28,12 +28,10 @@ import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.database.tree.DataStore;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
import org.apache.ignite.internal.processors.cache.database.tree.io.DataPageIO;
-import org.apache.ignite.internal.processors.query.h2.database.io.H2RowLinkIO;
import org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.query.h2.database.io.H2RowLinkIO;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
@@ -45,7 +43,7 @@ import static org.apache.ignite.internal.processors.cache.database.tree.util.Pag
/**
* Data store for H2 rows.
*/
-public class H2RowStore implements DataStore<GridH2Row> {
+public class H2RowStore {
/** */
private final PageMemory pageMem;
@@ -90,9 +88,15 @@ public class H2RowStore implements DataStore<GridH2Row> {
this.coctx = cctx.cacheObjectContext();
}
- /** {@inheritDoc} */
- @Override public GridH2Row getRow(BPlusIO<?> io, ByteBuffer buf, int idx) throws IgniteCheckedException {
- long link = ((H2RowLinkIO)io).getLink(buf, idx);
+ /**
+ * @param io IO.
+ * @param buf Buffer.
+ * @param idx Index.
+ * @return Row.
+ * @throws IgniteCheckedException If failed.
+ */
+ public GridH2Row getRow(H2RowLinkIO io, ByteBuffer buf, int idx) throws IgniteCheckedException {
+ long link = io.getLink(buf, idx);
return getRow(link);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index a9f8351..3e68e69 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -33,7 +33,6 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.cache.database.tree.DataStore;
import org.apache.ignite.internal.processors.query.h2.database.H2RowStore;
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.typedef.F;
@@ -93,7 +92,7 @@ public class GridH2Table extends TableBase {
private final boolean snapshotEnabled;
/** */
- private final H2RowStore dataStore;
+ private final H2RowStore rowStore;
/**
* Creates table.
@@ -112,7 +111,7 @@ public class GridH2Table extends TableBase {
this.desc = desc;
this.spaceName = spaceName;
- dataStore = idxsFactory.createDataStore(this);
+ rowStore = idxsFactory.createRowStore(this);
idxs = idxsFactory.createIndexes(this);
assert idxs != null;
@@ -410,10 +409,10 @@ public class GridH2Table extends TableBase {
desc.guard().begin();
try {
- if (dataStore != null) {
+ if (rowStore != null) {
assert row.link == 0;
- dataStore.writeRowData(row);
+ rowStore.writeRowData(row);
assert row.link != 0;
}
@@ -695,8 +694,8 @@ public class GridH2Table extends TableBase {
/**
* @return Data store.
*/
- public DataStore<GridH2Row> dataStore() {
- return dataStore;
+ public H2RowStore rowStore() {
+ return rowStore;
}
/**
@@ -775,7 +774,7 @@ public class GridH2Table extends TableBase {
* @param tbl Table.
* @return Data store.
*/
- H2RowStore createDataStore(GridH2Table tbl);
+ H2RowStore createRowStore(GridH2Table tbl);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/e895804d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
index d880dd5..000a515 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
@@ -88,7 +88,7 @@ public class GridH2TableSelfTest extends GridCommonAbstractTest {
conn = DriverManager.getConnection(DB_URL);
tbl = GridH2Table.Engine.createTable(conn, CREATE_TABLE_SQL, null, new GridH2Table.IndexesFactory() {
- @Override public H2RowStore createDataStore(GridH2Table tbl) {
+ @Override public H2RowStore createRowStore(GridH2Table tbl) {
return null;
}