ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [40/46] incubator-ignite git commit: ignite-sql-tests
Date Wed, 25 Feb 2015 00:37:03 GMT
ignite-sql-tests


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

Branch: refs/heads/ignite-sql-tests
Commit: 1b9a97adc0ca74b5d6e0c5056d092114ea300bd1
Parents: 6942a85
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Wed Feb 25 01:05:22 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Wed Feb 25 01:05:22 2015 +0300

----------------------------------------------------------------------
 examples/config/example-cache.xml               | 15 ++++++-------
 .../configuration/CacheConfiguration.java       | 23 ++++++++++++++++----
 .../processors/query/GridQueryProcessor.java    | 15 ++++++++-----
 .../query/h2/sql/GridQueryParsingTest.java      | 11 +++-------
 4 files changed, 39 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9a97ad/examples/config/example-cache.xml
----------------------------------------------------------------------
diff --git a/examples/config/example-cache.xml b/examples/config/example-cache.xml
index c685b46..1afb372 100644
--- a/examples/config/example-cache.xml
+++ b/examples/config/example-cache.xml
@@ -151,14 +151,13 @@
 
         <property name="indexedTypes">
             <list>
-                <bean class="org.apache.ignite.lang.IgniteBiTuple">
-                    <constructor-arg index="0" value="java.util.UUID"/>
-                    <constructor-arg index="1" value="org.apache.ignite.examples.datagrid.CacheQueryExample.Organization"/>
-                </bean>
-                <bean class="org.apache.ignite.lang.IgniteBiTuple">
-                    <constructor-arg index="0" value="java.util.UUID"/>
-                    <constructor-arg index="1" value="org.apache.ignite.examples.datagrid.CacheQueryExample.Person"/>
-                </bean>
+                <!-- Key and value type for SQL table Organization. -->
+                <value>java.util.UUID</value>
+                <value>org.apache.ignite.examples.datagrid.CacheQueryExample.Organization</value>
+
+                <!-- Key and value type for SQL table Person. -->
+                <value>java.util.UUID</value>
+                <value>org.apache.ignite.examples.datagrid.CacheQueryExample.Person</value>
             </list>
         </property>
     </bean>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9a97ad/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index ae1dba4..c74fcd3 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -25,7 +25,6 @@ import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.cache.store.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.configuration.*;
@@ -330,7 +329,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
     private boolean sqlEscapeAll;
 
     /** */
-    private IgniteBiTuple<Class<?>,Class<?>>[] indexedTypes;
+    private Class<?>[] indexedTypes;
 
     /** */
     private int sqlOnheapRowCacheSize = DFLT_SQL_ONHEAP_ROW_CACHE_SIZE;
@@ -1652,19 +1651,35 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
 
     /**
      * Array of key and value type pairs to be indexed.
+     * It means each even (0,2,4...) class in the array will be considered as key type for
cache entry,
+     * each odd (1,3,5...) class will be considered as value type for cache entry.
+     * <p>
+     * The same key class can occur multiple times for different value classes, but each
value class must be unique
+     * because SQL table will be named as value class simple name.
+     * <p>
+     * To expose fields of these types onto SQL level and to index them you have to use annotations
+     * from package {@link org.apache.ignite.cache.query.annotations}.
      *
      * @return Key and value type pairs.
      */
-    public IgniteBiTuple<Class<?>,Class<?>>[] getIndexedTypes() {
+    public Class<?>[] getIndexedTypes() {
         return indexedTypes;
     }
 
     /**
      * Array of key and value type pairs to be indexed.
+     * It means each even (0,2,4...) class in the array will be considered as key type for
cache entry,
+     * each odd (1,3,5...) class will be considered as value type for cache entry.
+     * <p>
+     * The same key class can occur multiple times for different value classes, but each
value class must be unique
+     * because SQL table will be named as value class simple name.
+     * <p>
+     * To expose fields of these types onto SQL level and to index them you have to use annotations
+     * from package {@link org.apache.ignite.cache.query.annotations}.
      *
      * @param indexedTypes Key and value type pairs.
      */
-    public void setIndexedTypes(IgniteBiTuple<Class<?>,Class<?>>... indexedTypes)
{
+    public void setIndexedTypes(Class<?>... indexedTypes) {
         this.indexedTypes = indexedTypes;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9a97ad/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 3baba76..985a887 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -130,14 +130,19 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             }
         }
 
-        if (!F.isEmpty(ccfg.getIndexedTypes())) {
-            for (IgniteBiTuple<Class<?>,Class<?>> types : ccfg.getIndexedTypes())
{
-                TypeDescriptor desc = processKeyAndValue(ccfg, types.getKey(), types.getValue(),
-                    declaredTypes);
+        Class<?>[] clss = ccfg.getIndexedTypes();
+
+        if (!F.isEmpty(clss)) {
+            for (int i = 0; i < clss.length; i += 2) {
+                Class<?> keyCls = clss[i];
+                Class<?> valCls = clss[i + 1];
+
+                TypeDescriptor desc = processKeyAndValueClasses(ccfg, keyCls, valCls, declaredTypes);
 
                 desc.registered(idx.registerType(ccfg.getName(), desc));
 
                 typesByName.put(new TypeName(ccfg.getName(), desc.name()), desc);
+                types.put(new TypeId(ccfg.getName(), valCls), desc);
             }
         }
     }
@@ -150,7 +155,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @return Type descriptor.
      * @throws IgniteCheckedException If failed.
      */
-    private TypeDescriptor processKeyAndValue(CacheConfiguration<?,?> ccfg, Class<?>
keyCls, Class<?> valCls,
+    private TypeDescriptor processKeyAndValueClasses(CacheConfiguration<?,?> ccfg,
Class<?> keyCls, Class<?> valCls,
         Map<TypeName,CacheTypeMetadata> declaredTypes)
         throws IgniteCheckedException {
         TypeDescriptor d = new TypeDescriptor(ccfg);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9a97ad/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index ffd23dd..80b03ae 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -24,7 +24,6 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.processors.query.h2.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.spi.discovery.tcp.*;
@@ -77,8 +76,9 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         cc.setSwapEnabled(false);
         cc.setSqlFunctionClasses(GridQueryParsingTest.class);
         cc.setIndexedTypes(
-            F.<Class<?>,Class<?>>t(String.class, Address.class),
-            F.<Class<?>,Class<?>>t(String.class, Person.class));
+            String.class, Address.class,
+            String.class, Person.class
+        );
 
         c.setCacheConfiguration(cc);
 
@@ -90,11 +90,6 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         super.beforeTestsStarted();
 
         ignite = startGrid();
-
-        GridCache cache = ((IgniteKernal)ignite).cache(null);
-
-        cache.putx("testAddr", new Address());
-        cache.putx("testPerson", new Person());
     }
 
     /**


Mime
View raw message