ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [3/7] ignite git commit: WIP.
Date Thu, 24 Aug 2017 14:57:37 GMT
WIP.


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

Branch: refs/heads/alpha_long_ids
Commit: 25f526f6d7f6ca6faf7e7a2294d103080ae75236
Parents: 26d7fa9
Author: devozerov <vozerov@gridgain.com>
Authored: Thu Aug 24 17:06:47 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Thu Aug 24 17:06:47 2017 +0300

----------------------------------------------------------------------
 examples/src/main/java/alpha/AlphaRunner.java | 37 ++++++++++++----------
 examples/src/main/java/alpha/OrderPojo.java   |  2 +-
 examples/src/main/java/alpha/sql_01.txt       |  8 ++---
 examples/src/main/java/alpha/sql_02.txt       | 28 ++++++++++++++++
 examples/src/main/java/alpha/sql_03.txt       | 25 +++++++++++++++
 5 files changed, 78 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/25f526f6/examples/src/main/java/alpha/AlphaRunner.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/alpha/AlphaRunner.java b/examples/src/main/java/alpha/AlphaRunner.java
index 5eecf96..d0efac1 100644
--- a/examples/src/main/java/alpha/AlphaRunner.java
+++ b/examples/src/main/java/alpha/AlphaRunner.java
@@ -95,28 +95,31 @@ public class AlphaRunner {
             // Explain.
             String sql = loadSql("sql_01.txt");
 
-            String explain = (String)cacheOrder.query(new SqlFieldsQuery("EXPLAIN " + sql)).getAll().get(0).get(0);
-
-            System.out.println();
-            System.out.println(">>> EXPLAIN:");
-            System.out.println(explain);
-            System.out.println();
+//            String explain = (String)cacheOrder.query(new SqlFieldsQuery("EXPLAIN " + sql)).getAll().get(0).get(0);
+//
+//            System.out.println();
+//            System.out.println(">>> EXPLAIN:");
+//            System.out.println(explain);
+//            System.out.println();
 
             // Query.
-            long startTs = System.currentTimeMillis();
+            for (int i = 0; i < 10_000; i++){
+                long startTs = System.currentTimeMillis();
 
-            int cnt = 0;
+                int cnt = 0;
 
-            for (List<?> row : cacheOrder.query(new SqlFieldsQuery(sql)).getAll())
{
-                //System.out.println(row);
+                for (List<?> row : cacheOrder.query(new SqlFieldsQuery(sql)).getAll())
{
+                    //System.out.println(row);
 
-                cnt++;
-            }
+                    cnt++;
+                }
 
-            long durTs = System.currentTimeMillis() - startTs;
+                long durTs = System.currentTimeMillis() - startTs;
 
-            System.out.println(">>> Count: " + cnt);
-            System.out.println(">>> Duration: " + durTs);
+                System.out.println(">>> Count: " + cnt);
+                System.out.println(">>> Duration: " + durTs);
+                System.out.println();
+            }
         }
     }
 
@@ -163,7 +166,7 @@ public class AlphaRunner {
         res.objUID = UUID.randomUUID().toString();
         res.farLeg = rand.nextBoolean();
 
-        res.dealType = rand.nextBoolean() ? "Buy" : "Sell";
+        res.dealType = rand.nextBoolean() ? 1 : 2;
 
         int buyerIdx = rand.nextInt(contractors.size());
         int sellerIdx = rand.nextInt(contractors.size() - 1);
@@ -224,7 +227,7 @@ public class AlphaRunner {
         ccfg.setReadFromBackup(true);
         ccfg.setStatisticsEnabled(false);
         ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        ccfg.setQueryParallelism(3);
+        ccfg.setQueryParallelism(4);
         ccfg.setRebalanceMode(CacheRebalanceMode.NONE);
 
         ccfg.setIndexedTypes(OrderPojo.Key.class, OrderPojo.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/25f526f6/examples/src/main/java/alpha/OrderPojo.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/alpha/OrderPojo.java b/examples/src/main/java/alpha/OrderPojo.java
index cdb74ef..2e955ef 100644
--- a/examples/src/main/java/alpha/OrderPojo.java
+++ b/examples/src/main/java/alpha/OrderPojo.java
@@ -23,7 +23,7 @@ public class OrderPojo {
     public boolean farLeg;
 
     @QuerySqlField(name = "DEAL_TYPE")
-    public String dealType;
+    public int dealType;
 
     @QuerySqlField(name = "BUYER_LEGAL_ENTITY", index = true)
     public String buyerLegalEntity;

http://git-wip-us.apache.org/repos/asf/ignite/blob/25f526f6/examples/src/main/java/alpha/sql_01.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/java/alpha/sql_01.txt b/examples/src/main/java/alpha/sql_01.txt
index 62cca80..e65687a 100644
--- a/examples/src/main/java/alpha/sql_01.txt
+++ b/examples/src/main/java/alpha/sql_01.txt
@@ -8,16 +8,16 @@ SELECT
 
     SUM(
 	    CASE
-            WHEN CUR_NO = 1 AND ((DEAL_TYPE = 'Buy' AND FAR_LEG = TRUE) OR (DEAL_TYPE = 'Sell'
AND FAR_LEG = FALSE)) THEN ABS(CUR1_AMOUNT)
-            WHEN CUR_NO = 2 AND ((DEAL_TYPE = 'Buy' AND FAR_LEG = FALSE) OR (DEAL_TYPE =
'Sell' AND FAR_LEG = TRUE)) THEN ABS(CUR2_AMOUNT)
+            WHEN CUR_NO = 1 AND ((DEAL_TYPE = 1 AND FAR_LEG = TRUE) OR (DEAL_TYPE = 2 AND
FAR_LEG = FALSE)) THEN ABS(CUR1_AMOUNT)
+            WHEN CUR_NO = 2 AND ((DEAL_TYPE = 1 AND FAR_LEG = FALSE) OR (DEAL_TYPE = 2 AND
FAR_LEG = TRUE)) THEN ABS(CUR2_AMOUNT)
             ELSE 0
 		END
 	) AS OBLIGATIONS,
 
     SUM(
 	    CASE
-            WHEN CUR_NO = 1 AND ((DEAL_TYPE = 'Buy' AND FAR_LEG = FALSE) OR (DEAL_TYPE =
'Sell' AND FAR_LEG = TRUE)) THEN ABS(CUR1_AMOUNT)
-            WHEN CUR_NO = 2 AND ((DEAL_TYPE = 'Buy' AND FAR_LEG = TRUE) OR (DEAL_TYPE = 'Sell'
AND FAR_LEG = FALSE)) THEN ABS(CUR2_AMOUNT)
+            WHEN CUR_NO = 1 AND ((DEAL_TYPE = 1 AND FAR_LEG = FALSE) OR (DEAL_TYPE = 2 AND
FAR_LEG = TRUE)) THEN ABS(CUR1_AMOUNT)
+            WHEN CUR_NO = 2 AND ((DEAL_TYPE = 1 AND FAR_LEG = TRUE) OR (DEAL_TYPE = 2 AND
FAR_LEG = FALSE)) THEN ABS(CUR2_AMOUNT)
             ELSE 0
 		END
 	) AS DEMANDS

http://git-wip-us.apache.org/repos/asf/ignite/blob/25f526f6/examples/src/main/java/alpha/sql_02.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/java/alpha/sql_02.txt b/examples/src/main/java/alpha/sql_02.txt
new file mode 100644
index 0000000..5131276
--- /dev/null
+++ b/examples/src/main/java/alpha/sql_02.txt
@@ -0,0 +1,28 @@
+SELECT
+    TRADER,
+
+	CASE CUR_NO
+        WHEN 1 THEN CURRENCY1
+        WHEN 2 THEN CURRENCY2
+    END AS CURRENCY,
+
+    DEAL_TYPE,
+    FAR_LEG,
+    SUM(ABS(CUR1_AMOUNT))
+
+FROM OrderPojo
+    LEFT JOIN CONTRACTORS.Contractor as contractors ON OrderPojo.BUYER_LEGAL_ENTITY = contractors.ID_LE
+    LEFT JOIN CONTRACTORS.Contractor as contractors2 ON OrderPojo.SELLER_LEGAL_ENTITY = contractors2.ID_LE
+    CROSS JOIN (SELECT C1 CUR_NO FROM (VALUES (1), (2)) AS V) AS CURS
+
+WHERE (contractors.ID_LE IS NOT NULL OR contractors2.ID_LE IS NOT NULL)
+
+GROUP
+	BY TRADER,
+    CASE CUR_NO
+        WHEN 1 THEN CURRENCY1
+        WHEN 2 THEN CURRENCY2
+	END,
+
+	DEAL_TYPE,
+    FAR_LEG
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/25f526f6/examples/src/main/java/alpha/sql_03.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/java/alpha/sql_03.txt b/examples/src/main/java/alpha/sql_03.txt
new file mode 100644
index 0000000..51ea4ea
--- /dev/null
+++ b/examples/src/main/java/alpha/sql_03.txt
@@ -0,0 +1,25 @@
+SELECT
+    TRADER,
+
+	CASE CUR_NO
+        WHEN 1 THEN CURRENCY1
+        WHEN 2 THEN CURRENCY2
+    END AS CURRENCY,
+
+    DEAL_TYPE,
+    FAR_LEG,
+    SUM(ABS(CUR1_AMOUNT))
+
+FROM OrderPojo
+    INNER JOIN CONTRACTORS.Contractor as contractors ON (OrderPojo.BUYER_LEGAL_ENTITY = contractors.ID_LE
OR OrderPojo.SELLER_LEGAL_ENTITY = contractors.ID_LE)
+    CROSS JOIN (SELECT C1 CUR_NO FROM (VALUES (1), (2)) AS V) AS CURS
+
+GROUP BY
+    TRADER,
+    CASE CUR_NO
+        WHEN 1 THEN CURRENCY1
+        WHEN 2 THEN CURRENCY2
+	END,
+
+	DEAL_TYPE,
+    FAR_LEG
\ No newline at end of file


Mime
View raw message