You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2015/07/29 16:48:10 UTC

[1/3] incubator-ignite git commit: #ignite-1170: remove unused fields in nodejs sql query.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1170 d301d938a -> 9a5df1afa


#ignite-1170: remove unused fields in nodejs sql query.


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

Branch: refs/heads/ignite-1170
Commit: e073d34ad2181f568bbdadc4bb39a1ff8f37e682
Parents: d301d93
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jul 29 17:02:26 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jul 29 17:02:26 2015 +0300

----------------------------------------------------------------------
 modules/nodejs/src/main/js/sql-fields-query.js | 18 ------------------
 1 file changed, 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e073d34a/modules/nodejs/src/main/js/sql-fields-query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/sql-fields-query.js b/modules/nodejs/src/main/js/sql-fields-query.js
index edc9f4c..7b07baa 100644
--- a/modules/nodejs/src/main/js/sql-fields-query.js
+++ b/modules/nodejs/src/main/js/sql-fields-query.js
@@ -25,8 +25,6 @@ function SqlFieldsQuery(sql) {
     this._arg = [];
     this._pageSz = 1;
     this._type = null;
-    this._endFunc = function(err) {console.log("Empty end function is called [err=" + err + "]")};
-    this._pageFunc = function(res) {console.log("Empty page function is called [res=" + res + "]")}
 }
 
 /**
@@ -53,22 +51,6 @@ SqlFieldsQuery.prototype.on = function(code, f) {
 
 /**
  * @this {SqlFieldsQuery}
- * @param res Query result
- */
-SqlFieldsQuery.prototype.end = function(err) {
-    this._endFunc(err);
-}
-
-/**
- * @this {SqlFieldsQuery}
- * @param res Query data
- */
-SqlFieldsQuery.prototype.page = function(res) {
-    this._pageFunc(res);
-}
-
-/**
- * @this {SqlFieldsQuery}
  * @param {int} pageSz Page size.
  */
 SqlFieldsQuery.prototype.setPageSize = function(pageSz) {


[2/3] incubator-ignite git commit: #ignite-1170: remove unused fields in nodejs sql query.

Posted by iv...@apache.org.
#ignite-1170: remove unused fields in nodejs sql query.


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

Branch: refs/heads/ignite-1170
Commit: efe24c41437ce13da7e8c6c727bfc6b77be14f18
Parents: e073d34
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jul 29 17:03:37 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jul 29 17:03:37 2015 +0300

----------------------------------------------------------------------
 modules/nodejs/src/main/js/sql-fields-query.js | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/efe24c41/modules/nodejs/src/main/js/sql-fields-query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/sql-fields-query.js b/modules/nodejs/src/main/js/sql-fields-query.js
index 7b07baa..4a03f96 100644
--- a/modules/nodejs/src/main/js/sql-fields-query.js
+++ b/modules/nodejs/src/main/js/sql-fields-query.js
@@ -24,7 +24,6 @@ function SqlFieldsQuery(sql) {
     this._sql = sql;
     this._arg = [];
     this._pageSz = 1;
-    this._type = null;
 }
 
 /**


[3/3] incubator-ignite git commit: #ignite-1170: add nodejs support for scan query.

Posted by iv...@apache.org.
#ignite-1170: add nodejs support for scan query.


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

Branch: refs/heads/ignite-1170
Commit: 9a5df1afa21ddb0e4544866c1e596898eb98e909
Parents: efe24c4
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jul 29 17:48:02 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jul 29 17:48:02 2015 +0300

----------------------------------------------------------------------
 modules/nodejs/src/main/js/apache-ignite.js     |  3 +-
 modules/nodejs/src/main/js/cache.js             | 22 +++++++--
 modules/nodejs/src/main/js/query.js             | 50 ++++++++++++++++++++
 modules/nodejs/src/main/js/scan-query.js        | 50 ++++++++++++++++++++
 modules/nodejs/src/main/js/sql-fields-query.js  | 49 ++-----------------
 .../ignite/internal/NodeJsSqlQuerySelfTest.java |  9 ++++
 modules/nodejs/src/test/js/test-query.js        | 49 ++++++++++++++++---
 7 files changed, 178 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/main/js/apache-ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/apache-ignite.js b/modules/nodejs/src/main/js/apache-ignite.js
index 053b88a..d4eb659 100644
--- a/modules/nodejs/src/main/js/apache-ignite.js
+++ b/modules/nodejs/src/main/js/apache-ignite.js
@@ -22,5 +22,6 @@ module.exports = {
     Ignite : require('./ignite.js').Ignite,
     Compute : require('./compute.js').Compute,
     SqlQuery : require('./sql-query.js').SqlQuery,
-    SqlFieldsQuery : require('./sql-fields-query.js').SqlFieldsQuery
+    SqlFieldsQuery : require('./sql-fields-query.js').SqlFieldsQuery,
+    ScanQuery : require('./scan-query.js').ScanQuery
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/main/js/cache.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/cache.js b/modules/nodejs/src/main/js/cache.js
index 1600eaa..a919a90 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -463,13 +463,19 @@ QueryCursor.prototype.isFinished = function() {
 
 QueryCursor.prototype._getQueryCommand = function() {
     if (this._init) {
+        this._init = false;
+
         if (this._qry.type() === "Sql") {
             return this._sqlQuery(this._qry);
         }
+        else if (this._qry.type() == "SqlFields") {
+            return this._sqlFieldsQuery(this._qry);
+        }
+        else if (this._qry.type() == "Scan") {
+            return this._scanQuery(this._qry);
+        }
 
-        this._init = false;
-
-        return this._sqlFieldsQuery(this._qry);
+        return null;
     }
 
     return this._cache._createCommand("qryfetch").addParam("qryId", this._res.queryId).
@@ -486,6 +492,16 @@ QueryCursor.prototype._sqlQuery = function(qry) {
         setPostData(JSON.stringify({"arg" : qry.arguments()}));
 }
 
+QueryCursor.prototype._scanQuery = function(qry) {
+    var cmd = new Command("qryscanexe").addParam("cacheName", this._cache._cacheName).
+        addParam("psz", qry.pageSize());
+
+    if (qry.filterClassName() != null)
+        cmd.addParam("classname", qry.filterClassName());
+
+    return cmd;
+}
+
 QueryCursor.prototype._createQueryCommand = function(name, qry) {
     return new Command(name).addParam("cacheName", this._cache._cacheName).
         addParam("qry", qry.query()).addParam("psz", qry.pageSize());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/main/js/query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/query.js b/modules/nodejs/src/main/js/query.js
new file mode 100644
index 0000000..576a95d
--- /dev/null
+++ b/modules/nodejs/src/main/js/query.js
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @this {Query}
+ */
+function Query() {
+    this._qryType = "";
+    this._pageSz = 1;
+}
+
+/**
+ * @this {Query}
+ * @param {int} pageSz Page size.
+ */
+Query.prototype.setPageSize = function(pageSz) {
+    this._pageSz = pageSz;
+}
+
+/**
+ * @this {Query}
+ * @returns pageSize
+ */
+Query.prototype.pageSize = function() {
+    return this._pageSz;
+}
+
+/**
+ * @this {Query}
+ * @returns "SqlFields"
+ */
+Query.prototype.type = function() {
+    return this._qryType;
+}
+
+exports.Query = Query;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/main/js/scan-query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/scan-query.js b/modules/nodejs/src/main/js/scan-query.js
new file mode 100644
index 0000000..876919c
--- /dev/null
+++ b/modules/nodejs/src/main/js/scan-query.js
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var Query = require("./query").Query
+
+/**
+ * @this {ScanQuery}
+ */
+function ScanQuery() {
+    Query.apply(this, arguments);
+    this._className = null;
+    this._qryType = "Scan";
+}
+
+ScanQuery.prototype = Query.prototype;
+
+ScanQuery.prototype.constructor = ScanQuery;
+
+
+/**
+ * @this {ScanQuery}
+ * @param type Filter class name
+ */
+ScanQuery.prototype.setFilterClassName = function(className) {
+    this._className = className;
+}
+
+/**
+ * @this {ScanQuery}
+ * @returns Filter class name
+ */
+ScanQuery.prototype.filterClassName = function() {
+    return this._className;
+}
+
+exports.ScanQuery = ScanQuery;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/main/js/sql-fields-query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/sql-fields-query.js b/modules/nodejs/src/main/js/sql-fields-query.js
index 4a03f96..82fbb93 100644
--- a/modules/nodejs/src/main/js/sql-fields-query.js
+++ b/modules/nodejs/src/main/js/sql-fields-query.js
@@ -15,46 +15,23 @@
  * limitations under the License.
  */
 
+var Query = require("./query").Query
+
 /**
  * @this {SqlFieldsQuery}
  * @param {string} Sql query
  */
 function SqlFieldsQuery(sql) {
+    Query.apply(this, arguments);
     this._qryType = "SqlFields";
     this._sql = sql;
     this._arg = [];
     this._pageSz = 1;
 }
 
-/**
- * Set the callbacks for query events.
- *
- * @this {SqlFieldsQuery}
- * @param {string} code Function code could be "end", "page"
- * @param function Functions "end" and "page" are one argument functions.
- */
-SqlFieldsQuery.prototype.on = function(code, f) {
-    switch(code) {
-        case "end":
-            this._endFunc = f;
-
-            break;
-        case "page":
-            this._pageFunc = f;
+SqlFieldsQuery.prototype = Query.prototype;
 
-            break;
-        default :
-            throw "Sql do not have method " + code;
-    }
-}
-
-/**
- * @this {SqlFieldsQuery}
- * @param {int} pageSz Page size.
- */
-SqlFieldsQuery.prototype.setPageSize = function(pageSz) {
-    this._pageSz = pageSz;
-}
+SqlFieldsQuery.prototype.constructor = SqlFieldsQuery;
 
 /**
  * @this {SqlFieldsQuery}
@@ -80,20 +57,4 @@ SqlFieldsQuery.prototype.arguments = function() {
     return this._arg;
 }
 
-/**
- * @this {SqlFieldsQuery}
- * @returns pageSize
- */
-SqlFieldsQuery.prototype.pageSize = function() {
-    return this._pageSz;
-}
-
-/**
- * @this {SqlFieldsQuery}
- * @returns "SqlFields"
- */
-SqlFieldsQuery.prototype.type = function() {
-    return this._qryType;
-}
-
 exports.SqlFieldsQuery = SqlFieldsQuery;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
index 22d7ad4..f290820 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
@@ -99,6 +99,15 @@ public class NodeJsSqlQuerySelfTest extends NodeJsAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testScanQuery() throws Exception {
+        initCache();
+
+        runJsScript("testScanQuery");
+    }
+
+    /**
      * Init cache.
      */
     private void initCache() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a5df1af/modules/nodejs/src/test/js/test-query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-query.js b/modules/nodejs/src/test/js/test-query.js
index 3d55886..cad653c 100644
--- a/modules/nodejs/src/test/js/test-query.js
+++ b/modules/nodejs/src/test/js/test-query.js
@@ -22,6 +22,7 @@ var assert = require("assert");
 var Ignite = require(TestUtils.scriptPath());
 var SqlQuery = Ignite.SqlQuery;
 var SqlFieldsQuery = Ignite.SqlFieldsQuery;
+var ScanQuery = Ignite.ScanQuery;
 
 testSqlQuery = function() {
     TestUtils.startIgniteNode().then(function(ignite) {
@@ -59,10 +60,46 @@ testSqlQuery = function() {
 
             cursor.nextPage().then(onQuery);
         }).catch(function(err) {
-            assert(err === null, err);
+            TestUtils.testFails(err);
         })
     }).catch(function(err) {
-        assert(err === null, err);
+        TestUtils.testFails(err);
+    });
+}
+
+testScanQuery = function() {
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var qry = new ScanQuery();
+
+        var fullRes = [];
+
+        function onQuery(cursor) {
+            var page = cursor.page();
+
+            fullRes = fullRes.concat(page);
+
+            if (cursor.isFinished()) {
+                console.log("Full result=" + JSON.stringify(fullRes));
+
+                assert(fullRes.length === 4, "Result length is not correct" +
+                    "[expected=1, val = " + fullRes.length + "]");
+
+                fullRes.sort();
+
+                assert(fullRes[0]["key"] >= 0,
+                    "Result has incorrect index [res=" + fullRes[0]["key"] + "]");
+
+                return ignite.cache("person").get("key");
+            }
+
+            return cursor.nextPage().then(onQuery);
+        }
+
+        ignite.cache("person").query(qry).nextPage().then(onQuery).then(function(){
+            TestUtils.testDone();
+        })
+    }).catch(function(err) {
+        TestUtils.testFails(err);
     });
 }
 
@@ -98,7 +135,7 @@ testSqlFieldsQuery = function() {
             TestUtils.testDone();
         })
     }).catch(function(err) {
-        assert(err === null, err);
+        TestUtils.testFails(err);
     });
 }
 
@@ -148,7 +185,7 @@ testSqlFieldsGetAllQuery = function() {
             TestUtils.testDone();
         })
     }).catch(function(err) {
-        assert(err === null, err);
+        TestUtils.testFails(err);
     });
 }
 
@@ -193,7 +230,7 @@ testSqlFieldsMeta = function() {
 
         ignite.cache("person").query(qry).nextPage().then(onQuery);
     }).catch(function(err) {
-        assert(err === null, err);
+        TestUtils.testFails(err);
     });
 }
 
@@ -232,6 +269,6 @@ testSqlQueryWithParams = function() {
 
         ignite.cache("person").query(qry).nextPage().then(onQuery);
     }).catch(function(err) {
-        assert(err === null, err);
+        TestUtils.testFails(err);
     });
 }
\ No newline at end of file