You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/07/11 09:03:44 UTC
[46/49] ignite git commit: IGNITE-5662 Primary index name should
contain type ID or name - Fixes #2275.
IGNITE-5662 Primary index name should contain type ID or name - Fixes #2275.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b3e6298a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b3e6298a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b3e6298a
Branch: refs/heads/ignite-2.1
Commit: b3e6298a099f684a293a61b97e7623f5400cc5d0
Parents: d2fe437
Author: Eduard Shangareev <es...@gridgain.com>
Authored: Mon Jul 10 20:44:29 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Jul 10 20:44:29 2017 +0300
----------------------------------------------------------------------
.../internal/processors/query/QueryUtils.java | 8 +-
...oreQueryWithMultipleClassesPerCacheTest.java | 185 +++++++++++++++++++
.../IgnitePdsWithIndexingTestSuite.java | 2 +
3 files changed, 193 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b3e6298a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 022d121..320b25a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -421,10 +421,12 @@ public class QueryUtils {
QueryTypeIdKey typeId;
QueryTypeIdKey altTypeId = null;
+ int valTypeId = ctx.cacheObjects().typeId(qryEntity.findValueType());
+
if (valCls == null || (binaryEnabled && !keyOrValMustDeserialize)) {
processBinaryMeta(ctx, qryEntity, desc);
- typeId = new QueryTypeIdKey(cacheName, ctx.cacheObjects().typeId(qryEntity.findValueType()));
+ typeId = new QueryTypeIdKey(cacheName, valTypeId);
if (valCls != null)
altTypeId = new QueryTypeIdKey(cacheName, valCls);
@@ -471,9 +473,11 @@ public class QueryUtils {
}
typeId = new QueryTypeIdKey(cacheName, valCls);
- altTypeId = new QueryTypeIdKey(cacheName, ctx.cacheObjects().typeId(qryEntity.findValueType()));
+ altTypeId = new QueryTypeIdKey(cacheName, valTypeId);
}
+ desc.typeId(valTypeId);
+
return new QueryTypeCandidate(typeId, altTypeId, desc);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b3e6298a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java
new file mode 100644
index 0000000..432f41f
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java
@@ -0,0 +1,185 @@
+/*
+ * 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.database;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
+
+/**
+ *
+ */
+public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** Cache name. */
+ private static final String CACHE_NAME = "test_cache";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ cfg.setCacheConfiguration(cacheCfg(CACHE_NAME));
+
+ PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration();
+
+ pCfg.setCheckpointingFrequency(1000);
+
+ cfg.setPersistentStoreConfiguration(pCfg);
+
+ return cfg;
+ }
+
+ /**
+ * @param name Cache name.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration cacheCfg(String name) {
+ CacheConfiguration<?, ?> cfg = new CacheConfiguration<>();
+
+ cfg.setName(name);
+
+ cfg.setRebalanceMode(CacheRebalanceMode.NONE);
+
+ cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+
+ cfg.setIndexedTypes(
+ Integer.class, Country.class,
+ Integer.class, Person.class
+ );
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");
+
+ stopAllGrids();
+
+ deleteWorkFiles();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ deleteWorkFiles();
+
+ System.clearProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimple() throws Exception {
+ IgniteEx ig0 = startGrid(0);
+
+ ig0.active(true);
+
+ ig0.cache(CACHE_NAME).put(0, new Person(0));
+
+ ig0.cache(CACHE_NAME).put(1, new Country());
+
+ List<List<?>> all = ig0.cache(CACHE_NAME)
+ .query(new SqlFieldsQuery("select depId FROM \"" + CACHE_NAME + "\".Person")).getAll();
+
+ assert all.size() == 1;
+
+ }
+
+ /**
+ * @throws IgniteCheckedException On error.
+ */
+ private void deleteWorkFiles() throws IgniteCheckedException {
+ deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+ }
+
+ /**
+ *
+ */
+ public static class Person implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ @QuerySqlField
+ protected int depId;
+
+ /** */
+ @QuerySqlField
+ protected String name;
+
+ /** */
+ @QuerySqlField
+ protected UUID id = UUID.randomUUID();
+
+
+ /** */
+ @SuppressWarnings("unused")
+ private Person() {
+ // No-op.
+ }
+
+ /**
+ * @param depId Department ID.
+ */
+ private Person(int depId) {
+ this.depId = depId;
+
+ name = "Name-" + id + " " + depId;
+ }
+ }
+
+
+ /**
+ *
+ */
+ public static class Country {
+ /** */
+ @QuerySqlField(index = true)
+ private int id;
+
+ /** */
+ @QuerySqlField
+ private String name;
+
+ /** */
+ @QuerySqlField
+ private UUID uuid = UUID.randomUUID();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b3e6298a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
index cb3cd1b..15ea594 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexi
import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest;
import org.apache.ignite.internal.processors.database.IgniteDbMultiNodeWithIndexingPutGetTest;
import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeWithIndexingPutGetTest;
+import org.apache.ignite.internal.processors.database.IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest;
import org.apache.ignite.internal.processors.database.IgnitePersistentStoreSchemaLoadTest;
/**
@@ -40,6 +41,7 @@ public class IgnitePdsWithIndexingTestSuite extends TestSuite {
suite.addTestSuite(IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.class);
suite.addTestSuite(IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.class);
suite.addTestSuite(IgnitePersistentStoreSchemaLoadTest.class);
+ suite.addTestSuite(IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.class);
return suite;
}