ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [20/43] ignite git commit: IGNITE-5420: CREATE TABLE command now generates unique key and value type names. This closes #2093.
Date Thu, 08 Jun 2017 12:33:13 GMT
IGNITE-5420: CREATE TABLE command now generates unique key and value type names. This closes
#2093.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f3c6b3c5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f3c6b3c5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f3c6b3c5

Branch: refs/heads/ignite-5414
Commit: f3c6b3c5a7b610f0aea3945f5378964dc60d77c4
Parents: 98cdcfd
Author: devozerov <vozerov@gridgain.com>
Authored: Tue Jun 6 15:48:26 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Tue Jun 6 15:48:26 2017 +0300

----------------------------------------------------------------------
 .../query/h2/ddl/DdlStatementsProcessor.java    | 20 +++++++++++++++--
 .../cache/index/H2DynamicTableSelfTest.java     | 23 +++++---------------
 2 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f3c6b3c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
index 060636b..251ee9f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
@@ -22,6 +22,8 @@ import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
+
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
@@ -288,9 +290,11 @@ public class DdlStatementsProcessor {
             res.addQueryField(e.getKey(), DataType.getTypeClassName(col.getType()), null);
         }
 
-        res.setKeyType(createTbl.tableName() + "Key");
+        String valTypeName = valueType(createTbl.schemaName(), createTbl.tableName());
+        String keyTypeName = valTypeName + "_Key";
 
-        res.setValueType(createTbl.tableName());
+        res.setValueType(valTypeName);
+        res.setKeyType(keyTypeName);
 
         res.setKeyFields(createTbl.primaryKeyColumns());
 
@@ -298,6 +302,18 @@ public class DdlStatementsProcessor {
     }
 
     /**
+     * Construct value type name for table.
+     *
+     * @param schemaName Schema name.
+     * @param tblName Table name.
+     * @return Value type name.
+     */
+    private static String valueType(String schemaName, String tblName) {
+        return "sql_" + schemaName + "_" + tblName + "_" + UUID.randomUUID().toString().replace("-",
"_");
+    }
+
+
+    /**
      * @param cmd Statement.
      * @return Whether {@code cmd} is a DDL statement we're able to handle.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/f3c6b3c5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
index 1d376c1..efb6cc8 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
@@ -27,8 +27,6 @@ import java.util.concurrent.Callable;
 import javax.cache.CacheException;
 
 import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicityMode;
@@ -51,7 +49,6 @@ import org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
 import org.apache.ignite.internal.processors.query.schema.SchemaOperationException;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.GridTestUtils;
 
 /**
@@ -191,12 +188,12 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
             QueryTypeDescriptorImpl desc = typeExisting(node, "Person", "Person");
 
             assertEquals(Object.class, desc.keyClass());
-
-            assertEquals("PersonKey", desc.keyTypeName());
-
             assertEquals(Object.class, desc.valueClass());
 
-            assertEquals("Person", desc.valueTypeName());
+            assertTrue(desc.valueTypeName(), desc.valueTypeName().contains("Person"));
+
+            assertTrue(desc.keyTypeName(), desc.keyTypeName().startsWith(desc.valueTypeName()));
+            assertTrue(desc.keyTypeName(), desc.keyTypeName().endsWith("Key"));
 
             assertEquals(
                 F.asList("id", "city", "name", "surname", "age"),
@@ -204,13 +201,9 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
             );
 
             assertProperty(desc, "id", Integer.class, true);
-
             assertProperty(desc, "city", String.class, true);
-
             assertProperty(desc, "name", String.class, false);
-
             assertProperty(desc, "surname", String.class, false);
-
             assertProperty(desc, "age", Integer.class, false);
 
             GridH2Table tbl = ((IgniteH2Indexing)node.context().query().getIndexing()).dataTable("PUBLIC",
"Person");
@@ -465,6 +458,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
      * @param params Engine parameters.
      * @param expErrMsg Expected error message.
      */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
     private void assertCreateTableWithParamsThrows(final String params, String expErrMsg)
{
         GridTestUtils.assertThrows(null, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -588,13 +582,6 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
-     * @return Cache to issue queries upon.
-     */
-    private IgniteCache<?, ?> cache() {
-        return client().cache(INDEXED_CACHE_NAME);
-    }
-
-    /**
      * @return Default cache configuration.
      */
     private CacheConfiguration cacheConfiguration() {


Mime
View raw message