Reworked table identifiers.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/40571fad Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/40571fad Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/40571fad Branch: refs/heads/ignite-5054-splitter-2 Commit: 40571fad4954d8560b112d416c9f0c82f4109e72 Parents: f71dac5 Author: devozerov <voze...@gridgain.com> Authored: Wed May 17 14:32:28 2017 +0300 Committer: devozerov <voze...@gridgain.com> Committed: Wed May 17 14:32:28 2017 +0300 ---------------------------------------------------------------------- .../processors/query/h2/IgniteH2Indexing.java | 19 +++++++++----- .../query/h2/opt/GridH2IndexBase.java | 2 +- .../processors/query/h2/opt/GridH2Table.java | 27 +++++++++++++++----- .../query/h2/sql/GridSqlQuerySplitter.java | 4 +-- .../query/h2/twostep/GridMapQueryExecutor.java | 2 +- 5 files changed, 37 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/40571fad/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 f545fd8..71935f4 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 @@ -399,7 +399,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { private DdlStatementsProcessor ddlProc; /** */ - private final ConcurrentMap<String, GridH2Table> dataTables = new ConcurrentHashMap8<>(); + private final ConcurrentMap<QueryTable, GridH2Table> dataTables = new ConcurrentHashMap8<>(); /** Statement cache. */ private final ConcurrentHashMap<Thread, StatementCache> stmtCache = new ConcurrentHashMap<>(); @@ -2010,7 +2010,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { addInitialUserIndex(spaceName, tbl, usrIdx); if (dataTables.putIfAbsent(h2Tbl.identifier(), h2Tbl) != null) - throw new IllegalStateException("Table already exists: " + h2Tbl.identifier()); + throw new IllegalStateException("Table already exists: " + h2Tbl.identifierString()); } /** @@ -2021,12 +2021,17 @@ public class IgniteH2Indexing implements GridQueryIndexing { * @return Table or {@code null} if none found. */ public GridH2Table dataTable(String schemaName, String tblName) { - for (GridH2Table tbl : dataTables.values()) { - if (tbl.getSchema().getName().equals(schemaName) && tbl.getName().equals(tblName)) - return tbl; - } + return dataTable(new QueryTable(schemaName, tblName)); + } - return null; + /** + * Find table by it's identifier. + * + * @param tbl Identifier. + * @return Table or {@code null} if none found. + */ + public GridH2Table dataTable(QueryTable tbl) { + return dataTables.get(tbl); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/40571fad/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java index 623da09..12850f4 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java @@ -132,7 +132,7 @@ public abstract class GridH2IndexBase extends BaseIndex { log = ctx.log(getClass()); - msgTopic = new IgniteBiTuple<>(GridTopic.TOPIC_QUERY, tbl.identifier() + '.' + getName()); + msgTopic = new IgniteBiTuple<>(GridTopic.TOPIC_QUERY, tbl.identifierString() + '.' + getName()); msgLsnr = new GridMessageListener() { @Override public void onMessage(UUID nodeId, Object msg) { http://git-wip-us.apache.org/repos/asf/ignite/blob/40571fad/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 a00ea90..a9f1f7d 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 @@ -32,6 +32,7 @@ import org.apache.ignite.IgniteInterruptedException; 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.query.QueryTable; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory; import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex; @@ -47,7 +48,6 @@ import org.h2.message.DbException; import org.h2.result.Row; import org.h2.result.SearchRow; import org.h2.result.SortOrder; -import org.h2.table.Column; import org.h2.table.IndexColumn; import org.h2.table.TableBase; import org.h2.table.TableType; @@ -58,7 +58,6 @@ import org.jsr166.LongAdder8; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.KEY_COL; -import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.VAL_COL; import static org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryType.MAP; /** @@ -104,6 +103,12 @@ public class GridH2Table extends TableBase { /** */ private volatile boolean rebuildFromHashInProgress; + /** Identifier. */ + private final QueryTable identifier; + + /** Identifier as string. */ + private final String identifierStr; + /** * Creates table. * @@ -171,6 +176,9 @@ public class GridH2Table extends TableBase { snapshotEnabled = desc == null || desc.snapshotableIndex(); lock = new ReentrantReadWriteLock(); + + identifier = new QueryTable(getSchema().getName(), getName()); + identifierStr = identifier.schema() + "." + identifier.table(); } /** @@ -221,7 +229,7 @@ public class GridH2Table extends TableBase { if (destroyed) { unlock(exclusive); - throw new IllegalStateException("Table " + identifier() + " already destroyed."); + throw new IllegalStateException("Table " + identifierString() + " already destroyed."); } if (snapshotInLock()) @@ -293,8 +301,15 @@ public class GridH2Table extends TableBase { /** * @return Table identifier. */ - public String identifier() { - return getSchema().getName() + '.' + getName(); + public QueryTable identifier() { + return identifier; + } + + /** + * @return Table identifier as string. + */ + public String identifierString() { + return identifierStr; } /** @@ -352,7 +367,7 @@ public class GridH2Table extends TableBase { */ private void ensureNotDestroyed() { if (destroyed) - throw new IllegalStateException("Table " + identifier() + " already destroyed."); + throw new IllegalStateException("Table " + identifierString() + " already destroyed."); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/40571fad/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java index b557e35..9f01346 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java @@ -1498,8 +1498,8 @@ public class GridSqlQuerySplitter { if (from instanceof GridSqlTable) { GridSqlTable tbl = (GridSqlTable)from; - String schemaName = tbl.schema(); - String tblName = tbl.dataTable().identifier(); + String schemaName = tbl.dataTable().identifier().schema(); + String tblName = tbl.dataTable().identifier().table(); tbls.add(new QueryTable(schemaName, tblName)); http://git-wip-us.apache.org/repos/asf/ignite/blob/40571fad/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java index 80bad5c..6570fc7 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java @@ -569,7 +569,7 @@ public class GridMapQueryExecutor { snapshotedTbls = new ArrayList<>(tbls.size()); for (QueryTable tbl : tbls) { - GridH2Table h2Tbl = h2.dataTable(tbl.schema(), tbl.table()); + GridH2Table h2Tbl = h2.dataTable(tbl); Objects.requireNonNull(h2Tbl, tbl.toString());