ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [3/3] incubator-ignite git commit: ignite-sql-tests - tests
Date Thu, 26 Feb 2015 00:10:04 GMT
ignite-sql-tests - 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/566287a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/566287a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/566287a1

Branch: refs/heads/ignite-sql-tests
Commit: 566287a1ac2a1096076537d8d8ad2b46a7adaf37
Parents: 17b75ae
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Feb 26 03:09:52 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Feb 26 03:09:52 2015 +0300

----------------------------------------------------------------------
 .../processors/query/h2/IgniteH2Indexing.java   | 28 +++++++++++-------
 .../h2/GridIndexingSpiAbstractSelfTest.java     | 30 ++++++++------------
 2 files changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/566287a1/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 7cf2d4f..1821c45 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
@@ -603,7 +603,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             long time = U.currentTimeMillis() - start;
 
-            long longQryExecTimeout = ctx.cache().cache(space).configuration().getLongQueryWarningTimeout();
+            long longQryExecTimeout = schemas.get(schema(space)).ccfg.getLongQueryWarningTimeout();
 
             if (time > longQryExecTimeout) {
                 String msg = "Query execution is too long (" + time + " ms): " + sql;
@@ -910,7 +910,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         assert schema != null;
         assert tbl != null;
 
-        boolean escapeAll = schema.escapeAll;
+        boolean escapeAll = schema.escapeAll();
 
         String keyType = dbTypeFromClass(tbl.type().keyClass());
         String valTypeStr = dbTypeFromClass(tbl.type().valueClass());
@@ -1263,7 +1263,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         String schema = schema(ccfg.getName());
 
         if (schemas.putIfAbsent(schema, new Schema(ccfg.getName(), ccfg.getOffHeapMaxMemory()
>= 0 ?
-            new GridUnsafeMemory(0) : null, ccfg.getSqlOnheapRowCacheSize(), ccfg.isSqlEscapeAll()))
!= null)
+            new GridUnsafeMemory(0) : null, ccfg)) != null)
             throw new IgniteCheckedException("Cache already registered: " + ccfg.getName());
 
         createSchema(schema);
@@ -1496,7 +1496,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             this.schema = schema;
 
             fullTblName = '\"' + IgniteH2Indexing.schema(schema.spaceName) + "\"." +
-                escapeName(type.name(), schema.escapeAll);
+                escapeName(type.name(), schema.escapeAll());
         }
 
         /**
@@ -1566,11 +1566,11 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
                     int i = 0;
 
-                    boolean escapeAll = schema.escapeAll;
+                    boolean escapeAll = schema.escapeAll();
 
                     for (String field : idx.fields()) {
                         // H2 reserved keywords used as column name is case sensitive.
-                        String fieldName = escapeAll ? field : escapeName(field, escapeAll).toUpperCase();
+                        String fieldName = escapeAll ? field : escapeName(field, false).toUpperCase();
 
                         Column col = tbl.getColumn(fieldName);
 
@@ -1779,19 +1779,20 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         private final CacheLongKeyLIRS<GridH2KeyValueRowOffheap> rowCache;
 
         /** */
-        private final boolean escapeAll;
+        private final CacheConfiguration<?,?> ccfg;
 
         /**
          * @param spaceName Space name.
          * @param offheap Offheap memory.
+         * @param ccfg Cache configuration.
          */
-        private Schema(@Nullable String spaceName, GridUnsafeMemory offheap, int onheapCacheSize,
boolean escapeAll) {
+        private Schema(@Nullable String spaceName, GridUnsafeMemory offheap, CacheConfiguration<?,?>
ccfg) {
             this.spaceName = spaceName;
             this.offheap = offheap;
-            this.escapeAll = escapeAll;
+            this.ccfg = ccfg;
 
             if (offheap != null)
-                rowCache = new CacheLongKeyLIRS<>(onheapCacheSize, 1, 128, 256);
+                rowCache = new CacheLongKeyLIRS<>(ccfg.getSqlOnheapRowCacheSize(),
1, 128, 256);
             else
                 rowCache = null;
         }
@@ -1803,6 +1804,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             if (tbls.putIfAbsent(tbl.name(), tbl) != null)
                 throw new IllegalStateException("Table already registered: " + tbl.name());
         }
+
+        /**
+         * @return Escape all.
+         */
+        public boolean escapeAll() {
+            return ccfg.isSqlEscapeAll();
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/566287a1/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 438cd10..4bb801b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -82,14 +82,14 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
     /** {@inheritDoc} */
     protected void startIndexing(IgniteH2Indexing spi) throws Exception {
+        spi.start(null);
+
         spi.registerCache(cacheCfg("A"));
         spi.registerCache(cacheCfg("B"));
-
-        spi.start(null);
     }
 
     private CacheConfiguration cacheCfg(String name) {
-        CacheConfiguration cfg = new CacheConfiguration<Object,Object>();
+        CacheConfiguration<?,?> cfg = new CacheConfiguration<>();
 
         cfg.setName(name);
 
@@ -253,7 +253,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
         // Query data.
         Iterator<IgniteBiTuple<Integer, Map<String, Object>>> res =
-            spi.query(typeAA.space(), "select * from a order by age", Collections.emptySet(),
typeAA, null);
+            spi.query(typeAA.space(), "from a order by age", Collections.emptySet(), typeAA,
null);
 
         assertTrue(res.hasNext());
         assertEquals(aa(3, "Borya", 18), value(res.next()));
@@ -261,7 +261,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         assertEquals(aa(2, "Valera", 19), value(res.next()));
         assertFalse(res.hasNext());
 
-        res = spi.query(typeAB.space(), "select * from b order by name", Collections.emptySet(),
typeAB, null);
+        res = spi.query(typeAB.space(), "from b order by name", Collections.emptySet(), typeAB,
null);
 
         assertTrue(res.hasNext());
         assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here."), value(res.next()));
@@ -269,7 +269,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         assertEquals(ab(4, "Vitalya", 20, "Very Good guy"), value(res.next()));
         assertFalse(res.hasNext());
 
-        res = spi.query(typeBA.space(), "select * from a", Collections.emptySet(), typeBA,
null);
+        res = spi.query(typeBA.space(), "from a", Collections.emptySet(), typeBA, null);
 
         assertTrue(res.hasNext());
         assertEquals(ba(2, "Kolya", 25, true), value(res.next()));
@@ -285,7 +285,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
         // Fields query
         GridQueryFieldsResult fieldsRes =
-            spi.queryFields(null, "select a.a.name n1, a.a.age a1, b.a.name n2, " +
+            spi.queryFields("A", "select a.a.name n1, a.a.age a1, b.a.name n2, " +
             "b.a.age a2 from a.a, b.a where a.a.id = b.a.id ", Collections.emptySet(), null);
 
         String[] aliases = {"N1", "A1", "N2", "A2"};
@@ -306,10 +306,6 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
         assertFalse(fieldsRes.iterator().hasNext());
 
-        // Query on not existing table should not fail.
-        assertFalse(spi.queryFields(null, "select * from not_existing_table",
-            Collections.emptySet(), null).iterator().hasNext());
-
         // Remove
         spi.remove(typeAA.space(), 2);
 
@@ -389,7 +385,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
                 time = now;
                 range *= 3;
 
-                GridQueryFieldsResult res = spi.queryFields(null, sql, Arrays.<Object>asList(1,
range), null);
+                GridQueryFieldsResult res = spi.queryFields("A", sql, Arrays.<Object>asList(1,
range), null);
 
                 assert res.iterator().hasNext();
 
@@ -495,18 +491,16 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         }
 
         /** {@inheritDoc} */
+        @SuppressWarnings("unchecked")
         @Override public <T> T value(String field, Object key, Object val) throws IgniteSpiException
{
             assert !F.isEmpty(field);
 
-            Map m = (Map)key;
-
-            if (m.containsKey(field))
-                return (T)m.get(field);
+            assert key instanceof Integer;
 
-            m = (Map)val;
+            Map<String, T> m = (Map<String, T>)val;
 
             if (m.containsKey(field))
-                return (T)m.get(field);
+                return m.get(field);
 
             return null;
         }


Mime
View raw message