ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [6/7] incubator-ignite git commit: #ignite-965: js __internalCall can use only 2 arguments.
Date Wed, 24 Jun 2015 12:48:41 GMT
#ignite-965: js __internalCall can use only 2 arguments.


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

Branch: refs/heads/ignite-965
Commit: 3989b84f3593b4713b6c61b6b3fc1be77b4b3b12
Parents: 99d2c2a
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Wed Jun 24 15:46:32 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Wed Jun 24 15:46:32 2015 +0300

----------------------------------------------------------------------
 .../scripting/IgniteScriptingCommandHandler.java      |  9 +--------
 .../processors/scripting/IgniteScriptProcessor.java   | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3989b84f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
index b48671e..c41315b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
@@ -60,13 +60,7 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
             String emitFunction = "function emit(f, args, nodeId) {" +
                 "__emitResult.add(f.toString(), args, nodeId);}";
 
-            String computeFunction = "function __compute(mapFuncSource, ids, args) {"  +
-                "       var f = __createJSFunction(mapFuncSource);" +
-                "       f(ids, args); "  +
-                "   }";
-
             script.addEngineFunction(emitFunction);
-            script.addEngineFunction(computeFunction);
 
             emitRes = new IgniteJsEmitResult();
 
@@ -159,8 +153,7 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
             try {
                 Map<ComputeJob, ClusterNode> map = new HashMap<>();
 
-                ctx.scripting().invokeFunctionByName("__compute",
-                    mapFunc, nodes.toArray(new ClusterNode[nodes.size()]), this.arg);
+                ctx.scripting().invokeFunction(mapFunc, nodes.toArray(new ClusterNode[nodes.size()]),
this.arg);
 
                 List<T3<Object, Object, Object>> jsMapRes = emitRes.getEmitResult();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3989b84f/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
index e1eb8b7..b48b0c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
@@ -57,9 +57,9 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
         String createJSFunction = "function __createJSFunction(mapFunc) {" +
                 "return eval('(function() { return ' + mapFunc.trim() + '})()'); }";
 
-        String internalCall  = "function __internalCall(funcSource, arg) { " +
+        String internalCall  = "function __internalCall(funcSource, arg1, arg2) { " +
             "var func = __createJSFunction(funcSource); " +
-            "return func.apply(null, arg); }";
+            "return func.apply(null, arg1, arg2); }";
 
         addEngineFunction(createJSFunction);
         addEngineFunction(internalCall);
@@ -114,6 +114,16 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * @param src Script src.
+     * @param arg Argument.
+     * @return Result of the function.
+     * @throws IgniteCheckedException If script failed.
+     */
+    public Object invokeFunction(String src, Object arg, Object arg2) throws IgniteCheckedException
{
+        return invokeFunctionByName("__internalCall", src, arg, arg2);
+    }
+
+    /**
      * Invoke function.
      *
      * @param nameFunc Function name.


Mime
View raw message