You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/08/20 14:13:58 UTC
[1/2] incubator-ignite git commit: master - added test for group
index bug
Repository: incubator-ignite
Updated Branches:
refs/heads/master 75aee0890 -> 452af6a67
master - added test for group index bug
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/515a8792
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/515a8792
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/515a8792
Branch: refs/heads/master
Commit: 515a8792bc0b5705d7ef556c0b54aba838fe4938
Parents: e18147d
Author: S.Vladykin <sv...@gridgain.com>
Authored: Thu Aug 20 15:12:21 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Thu Aug 20 15:12:21 2015 +0300
----------------------------------------------------------------------
.../query/IgniteSqlSplitterSelfTest.java | 123 ++++++++++++++-----
1 file changed, 93 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/515a8792/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 6ec6bb3..f97e4d2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -20,13 +20,16 @@ package org.apache.ignite.internal.processors.query;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
+import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.testframework.junits.common.*;
+import java.io.*;
import java.util.*;
/**
@@ -101,35 +104,65 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
String qry = "select _val from Integer order by _val ";
- assertEqualsCollections(res,
- column(0, c.query(new SqlFieldsQuery(qry)).getAll()));
-
- assertEqualsCollections(res.subList(0, 0),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ?").setArgs(0)).getAll()));
-
- assertEqualsCollections(res.subList(0, 3),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ?").setArgs(3)).getAll()));
-
- assertEqualsCollections(res.subList(0, 9),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset ?").setArgs(9, 0)).getAll()));
-
- assertEqualsCollections(res.subList(3, 7),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset ?").setArgs(4, 3)).getAll()));
-
- assertEqualsCollections(res.subList(7, 9),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset ?").setArgs(2, 7)).getAll()));
-
- assertEqualsCollections(res.subList(8, 10),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset ?").setArgs(2, 8)).getAll()));
-
- assertEqualsCollections(res.subList(9, 10),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset ?").setArgs(1, 9)).getAll()));
+ assertEqualsCollections(res, columnQuery(c, qry));
+ assertEqualsCollections(res.subList(0, 0), columnQuery(c, qry + "limit ?", 0));
+ assertEqualsCollections(res.subList(0, 3), columnQuery(c, qry + "limit ?", 3));
+ assertEqualsCollections(res.subList(0, 9), columnQuery(c, qry + "limit ? offset ?", 9, 0));
+ assertEqualsCollections(res.subList(3, 7), columnQuery(c, qry + "limit ? offset ?", 4, 3));
+ assertEqualsCollections(res.subList(7, 9), columnQuery(c, qry + "limit ? offset ?", 2, 7));
+ assertEqualsCollections(res.subList(8, 10), columnQuery(c, qry + "limit ? offset ?", 2, 8));
+ assertEqualsCollections(res.subList(9, 10), columnQuery(c, qry + "limit ? offset ?", 1, 9));
+ assertEqualsCollections(res.subList(10, 10), columnQuery(c, qry + "limit ? offset ?", 1, 10));
+ assertEqualsCollections(res.subList(9, 10), columnQuery(c, qry + "limit ? offset abs(-(4 + ?))", 1, 5));
+ }
+ finally {
+ c.destroy();
+ }
+ }
- assertEqualsCollections(res.subList(10, 10),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset ?").setArgs(1, 10)).getAll()));
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGroupIndexOperations() throws Exception {
+ IgniteCache<Integer, GroupIndexTestValue> c = ignite(0).getOrCreateCache(cacheConfig("grp", false,
+ Integer.class, GroupIndexTestValue.class));
- assertEqualsCollections(res.subList(9, 10),
- column(0, c.query(new SqlFieldsQuery(qry + "limit ? offset abs(-(4 + ?))").setArgs(1, 5)).getAll()));
+ try {
+ // Check group index usage.
+ String qry = "select 1 from GroupIndexTestValue ";
+
+ String plan = columnQuery(c, "explain " + qry + "where a = 1 and b > 0")
+ .get(0).toString();
+
+ info("Plan: " + plan);
+
+ assertTrue(plan.contains("grpIdx"));
+
+ // Sorted list
+ List<GroupIndexTestValue> list = F.asList(
+ new GroupIndexTestValue(0, 0),
+ new GroupIndexTestValue(0, 5),
+ new GroupIndexTestValue(1, 1),
+ new GroupIndexTestValue(1, 3),
+ new GroupIndexTestValue(2, -1),
+ new GroupIndexTestValue(2, 2)
+ );
+
+ // Fill cache.
+ for (int i = 0; i < list.size(); i++)
+ c.put(i, list.get(i));
+
+ // Check results.
+ assertEquals(1, columnQuery(c, qry + "where a = 1 and b = 1").size());
+ assertEquals(2, columnQuery(c, qry + "where a = 1 and b < 4").size());
+ assertEquals(2, columnQuery(c, qry + "where a = 1 and b <= 3").size());
+ assertEquals(1, columnQuery(c, qry + "where a = 1 and b < 3").size());
+ assertEquals(2, columnQuery(c, qry + "where a = 1 and b > 0").size());
+ assertEquals(1, columnQuery(c, qry + "where a = 1 and b > 1").size());
+ assertEquals(2, columnQuery(c, qry + "where a = 1 and b >= 1").size());
+ assertEquals(4, columnQuery(c, qry + "where a > 0 and b > 0").size());
+ assertEquals(4, columnQuery(c, qry + "where a > 0 and b >= 1").size());
+ assertEquals(3, columnQuery(c, qry + "where a > 0 and b > 1").size());
}
finally {
c.destroy();
@@ -137,16 +170,46 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
}
/**
+ * @param c Cache.
+ * @param qry Query.
+ * @param args Arguments.
+ * @return Column as list.
+ */
+ private static <X> List<X> columnQuery(IgniteCache<?,?> c, String qry, Object... args) {
+ return column(0, c.query(new SqlFieldsQuery(qry).setArgs(args)).getAll());
+ }
+
+ /**
* @param idx Column index.
* @param rows Rows.
* @return Column as list.
*/
- private static List<?> column(int idx, List<List<?>> rows) {
- List res = new ArrayList<>(rows.size());
+ private static <X> List<X> column(int idx, List<List<?>> rows) {
+ List<X> res = new ArrayList<>(rows.size());
for (List<?> row : rows)
- res.add(row.get(idx));
+ res.add((X)row.get(idx));
return res;
}
+
+ /**
+ * Test value.
+ */
+ private static class GroupIndexTestValue implements Serializable {
+ @QuerySqlField(orderedGroups = @QuerySqlField.Group(name = "grpIdx", order = 0))
+ private int a;
+
+ @QuerySqlField(orderedGroups = @QuerySqlField.Group(name = "grpIdx", order = 1))
+ private int b;
+
+ /**
+ * @param a A.
+ * @param b B.
+ */
+ private GroupIndexTestValue(int a, int b) {
+ this.a = a;
+ this.b = b;
+ }
+ }
}
[2/2] incubator-ignite git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-ignite
Posted by se...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-ignite
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/452af6a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/452af6a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/452af6a6
Branch: refs/heads/master
Commit: 452af6a67539aeef95befa4a9d7a8eaf3431a7db
Parents: 515a879 75aee08
Author: S.Vladykin <sv...@gridgain.com>
Authored: Thu Aug 20 15:12:32 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Thu Aug 20 15:12:32 2015 +0300
----------------------------------------------------------------------
.../internal/interop/InteropIgnition.java | 55 --------------------
.../internal/interop/InteropProcessor.java | 12 -----
.../util/nio/ssl/BlockingSslHandler.java | 2 +-
.../ignite/testframework/GridTestUtils.java | 2 +-
4 files changed, 2 insertions(+), 69 deletions(-)
----------------------------------------------------------------------