Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id ACF46200CFE for ; Thu, 24 Aug 2017 16:57:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id ABB5816AF9D; Thu, 24 Aug 2017 14:57:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E24E216AF9E for ; Thu, 24 Aug 2017 16:57:36 +0200 (CEST) Received: (qmail 7775 invoked by uid 500); 24 Aug 2017 14:57:36 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 7709 invoked by uid 99); 24 Aug 2017 14:57:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2017 14:57:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1A558F16B2; Thu, 24 Aug 2017 14:57:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Thu, 24 Aug 2017 14:57:36 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/7] ignite git commit: WIP. archived-at: Thu, 24 Aug 2017 14:57:37 -0000 WIP. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/26d7fa98 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/26d7fa98 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/26d7fa98 Branch: refs/heads/alpha_long_ids Commit: 26d7fa9848ce72e007327bb553ca2ae174fdc209 Parents: 79a908c Author: devozerov Authored: Thu Aug 24 16:07:37 2017 +0300 Committer: devozerov Committed: Thu Aug 24 16:07:37 2017 +0300 ---------------------------------------------------------------------- examples/src/main/java/alpha/AlphaRunner.java | 49 ++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/26d7fa98/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 8aa3c89..5eecf96 100644 --- a/examples/src/main/java/alpha/AlphaRunner.java +++ b/examples/src/main/java/alpha/AlphaRunner.java @@ -14,6 +14,9 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.InputStreamReader; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; @@ -44,7 +47,7 @@ public class AlphaRunner { /** * Entry point. */ - public static void main(String[] args) { + public static void main(String[] args) throws Exception { try (Ignite node = Ignition.start(new IgniteConfiguration().setLocalHost("127.0.0.1"))) { // Start caches IgniteCache cacheContractor = node.getOrCreateCache(cacheContractorConfiguration()); @@ -89,15 +92,30 @@ public class AlphaRunner { System.out.println(">>> Loaded orders."); + // 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(); + // Query. long startTs = System.currentTimeMillis(); - for (List row : cacheOrder.query(new SqlFieldsQuery(AlphaSql.QRY))) { - System.out.println(row); + int cnt = 0; + + for (List row : cacheOrder.query(new SqlFieldsQuery(sql)).getAll()) { + //System.out.println(row); + + cnt++; } long durTs = System.currentTimeMillis() - startTs; + System.out.println(">>> Count: " + cnt); System.out.println(">>> Duration: " + durTs); } } @@ -254,4 +272,29 @@ public class AlphaRunner { return idx; } + + /** + * Load SQL from a file. + * + * @param file File. + * @return SQL. + * @throws Exception If failed. + */ + private static String loadSql(String file) throws Exception { + StringBuilder res = new StringBuilder(); + + String path = "C:\\Personal\\code\\incubator-ignite\\examples\\src\\main\\java\\alpha\\" + file; + + try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path)))) { + String next = br.readLine(); + + while (next != null) { + res.append(next).append("\n"); + + next = br.readLine(); + } + } + + return res.toString(); + } }