{"action":"created","comment":{"url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/comments/75632398","id":75632398,"diff_hunk":"@@ -0,0 +1,139 @@\n+//\n+//Copyright 2016  Cityzen Data\n+//\n+//Licensed under the Apache License, Version 2.0 (the \"License\");\n+//you may not use this file except in compliance with the License.\n+//You may obtain a copy of the License at\n+//\n+//http://www.apache.org/licenses/LICENSE-2.0\n+//\n+//Unless required by applicable law or agreed to in writing, software\n+//distributed under the License is distributed on an \"AS IS\" BASIS,\n+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+//See the License for the specific language governing permissions and\n+//limitations under the License.\n+//\n+\n+package io.warp10.script.aggregator;\n+\n+import io.warp10.continuum.gts.GeoTimeSerie;\n+import io.warp10.continuum.gts.GeoTimeSerie.TYPE;\n+import io.warp10.script.NamedWarpScriptFunction;\n+import io.warp10.script.WarpScriptAggregatorFunction;\n+import io.warp10.script.WarpScriptBucketizerFunction;\n+import io.warp10.script.WarpScriptMapperFunction;\n+import io.warp10.script.WarpScriptReducerFunction;\n+import io.warp10.script.WarpScriptException;\n+\n+import com.geoxp.GeoXPLib;\n+\n+/**\n+ * Return the operation and of the values on the interval.\n+ * The returned location will be the centroid of all locations.\n+ * The returned elevation will be the average of all elevations.\n+ */\n+public class And extends NamedWarpScriptFunction implements WarpScriptAggregatorFunction, WarpScriptMapperFunction, WarpScriptBucketizerFunction, WarpScriptReducerFunction {\n+\n+  private final boolean ignoreNulls;\n+\n+  public And(String name, boolean ignoreNulls) {\n+    super(name);\n+    this.ignoreNulls = ignoreNulls;\n+  }\n+\n+  @Override\n+  public Object apply(Object[] args) throws WarpScriptException {\n+    long[] ticks = (long[]) args[3];\n+    long[] locations = (long[]) args[4];\n+    long[] elevations = (long[]) args[5];\n+    Object[] values = (Object[]) args[6];\n+\n+    if (0 == ticks.length) {\n+      return new Object[] { Long.MAX_VALUE, GeoTimeSerie.NO_LOCATION, GeoTimeSerie.NO_ELEVATION, null };\n+    }\n+\n+    TYPE andType = TYPE.UNDEFINED;\n+    Boolean res = true;\n+    long tickand = 0L;\n+    long latitudes = 0L;\n+    long longitudes = 0L;\n+    int locationcount = 0;\n+    long elev = 0L;\n+    int elevationcount = 0;\n+\n+    int nulls = 0;\n+\n+    for (int i = 0; i < values.length; i++) {\n+      Object value = values[i];\n+\n+      if (null == value) {\n+        nulls++;\n+        continue;\n+        //return new Object[] { Long.MAX_VALUE, GeoTimeSerie.NO_LOCATION, GeoTimeSerie.NO_ELEVATION, null };\n+      } else {\n+\n+        tickand += ticks[i] - ticks[0];\n+\n+        if (GeoTimeSerie.NO_LOCATION != locations[i]) {\n+          long[] xy = GeoXPLib.xyFromGeoXPPoint(locations[i]);\n+          latitudes += xy[0];\n+          longitudes += xy[1];\n+          locationcount++;\n+        }\n+\n+        if (GeoTimeSerie.NO_ELEVATION != elevations[i]) {\n+          elev += elevations[i];\n+          elevationcount++;\n+        }\n+\n+        if (TYPE.BOOLEAN == andType) {\n+          res = res && ((Boolean) value).booleanValue();\n+        } else {\n+          // No type detected yet,\n+          // check value\n+\n+          if (value instanceof Boolean) {\n+            andType = TYPE.BOOLEAN;\n+            res = ((Boolean) value).booleanValue();\n+          } else {\n+            \n+            //\n+            // And with an other type than Boolean has no meaning\n+            //\n+            return new Object[] { Long.MAX_VALUE, GeoTimeSerie.NO_LOCATION, GeoTimeSerie.NO_ELEVATION, null };","path":"warp10/src/main/java/io/warp10/script/aggregator/And.java","position":103,"original_position":103,"commit_id":"53cf3878e2f1ae7d585b281089dcec50d4875274","original_commit_id":"53cf3878e2f1ae7d585b281089dcec50d4875274","user":{"login":"hbs","id":236594,"avatar_url":"https://avatars.githubusercontent.com/u/236594?v=3","gravatar_id":"","url":"https://api.github.com/users/hbs","html_url":"https://github.com/hbs","followers_url":"https://api.github.com/users/hbs/followers","following_url":"https://api.github.com/users/hbs/following{/other_user}","gists_url":"https://api.github.com/users/hbs/gists{/gist_id}","starred_url":"https://api.github.com/users/hbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbs/subscriptions","organizations_url":"https://api.github.com/users/hbs/orgs","repos_url":"https://api.github.com/users/hbs/repos","events_url":"https://api.github.com/users/hbs/events{/privacy}","received_events_url":"https://api.github.com/users/hbs/received_events","type":"User","site_admin":false},"body":"Adopt the same semantics as that of OpAnd and OpOr instead of returning null.","created_at":"2016-08-22T08:02:41Z","updated_at":"2016-08-22T08:02:41Z","html_url":"https://github.com/cityzendata/warp10-platform/pull/79#discussion_r75632398","pull_request_url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79","_links":{"self":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/comments/75632398"},"html":{"href":"https://github.com/cityzendata/warp10-platform/pull/79#discussion_r75632398"},"pull_request":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79"}}},"pull_request":{"url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79","id":82147971,"html_url":"https://github.com/cityzendata/warp10-platform/pull/79","diff_url":"https://github.com/cityzendata/warp10-platform/pull/79.diff","patch_url":"https://github.com/cityzendata/warp10-platform/pull/79.patch","issue_url":"https://api.github.com/repos/cityzendata/warp10-platform/issues/79","number":79,"state":"open","locked":false,"title":"Add aggrator And and Or to use both operator as bucketizer, mapper an…","user":{"login":"aurrelhebert","id":2650661,"avatar_url":"https://avatars.githubusercontent.com/u/2650661?v=3","gravatar_id":"","url":"https://api.github.com/users/aurrelhebert","html_url":"https://github.com/aurrelhebert","followers_url":"https://api.github.com/users/aurrelhebert/followers","following_url":"https://api.github.com/users/aurrelhebert/following{/other_user}","gists_url":"https://api.github.com/users/aurrelhebert/gists{/gist_id}","starred_url":"https://api.github.com/users/aurrelhebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aurrelhebert/subscriptions","organizations_url":"https://api.github.com/users/aurrelhebert/orgs","repos_url":"https://api.github.com/users/aurrelhebert/repos","events_url":"https://api.github.com/users/aurrelhebert/events{/privacy}","received_events_url":"https://api.github.com/users/aurrelhebert/received_events","type":"User","site_admin":false},"body":"…d reducer","created_at":"2016-08-22T07:58:02Z","updated_at":"2016-08-22T08:02:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"598918ebc27a02ca7013f3e79aab554932912fde","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79/commits","review_comments_url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79/comments","review_comment_url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cityzendata/warp10-platform/issues/79/comments","statuses_url":"https://api.github.com/repos/cityzendata/warp10-platform/statuses/53cf3878e2f1ae7d585b281089dcec50d4875274","head":{"label":"aurrelhebert:master","ref":"master","sha":"53cf3878e2f1ae7d585b281089dcec50d4875274","user":{"login":"aurrelhebert","id":2650661,"avatar_url":"https://avatars.githubusercontent.com/u/2650661?v=3","gravatar_id":"","url":"https://api.github.com/users/aurrelhebert","html_url":"https://github.com/aurrelhebert","followers_url":"https://api.github.com/users/aurrelhebert/followers","following_url":"https://api.github.com/users/aurrelhebert/following{/other_user}","gists_url":"https://api.github.com/users/aurrelhebert/gists{/gist_id}","starred_url":"https://api.github.com/users/aurrelhebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aurrelhebert/subscriptions","organizations_url":"https://api.github.com/users/aurrelhebert/orgs","repos_url":"https://api.github.com/users/aurrelhebert/repos","events_url":"https://api.github.com/users/aurrelhebert/events{/privacy}","received_events_url":"https://api.github.com/users/aurrelhebert/received_events","type":"User","site_admin":false},"repo":{"id":53335553,"name":"warp10-platform","full_name":"aurrelhebert/warp10-platform","owner":{"login":"aurrelhebert","id":2650661,"avatar_url":"https://avatars.githubusercontent.com/u/2650661?v=3","gravatar_id":"","url":"https://api.github.com/users/aurrelhebert","html_url":"https://github.com/aurrelhebert","followers_url":"https://api.github.com/users/aurrelhebert/followers","following_url":"https://api.github.com/users/aurrelhebert/following{/other_user}","gists_url":"https://api.github.com/users/aurrelhebert/gists{/gist_id}","starred_url":"https://api.github.com/users/aurrelhebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aurrelhebert/subscriptions","organizations_url":"https://api.github.com/users/aurrelhebert/orgs","repos_url":"https://api.github.com/users/aurrelhebert/repos","events_url":"https://api.github.com/users/aurrelhebert/events{/privacy}","received_events_url":"https://api.github.com/users/aurrelhebert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aurrelhebert/warp10-platform","description":"","fork":true,"url":"https://api.github.com/repos/aurrelhebert/warp10-platform","forks_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/forks","keys_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/teams","hooks_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/hooks","issue_events_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/issues/events{/number}","events_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/events","assignees_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/assignees{/user}","branches_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/branches{/branch}","tags_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/tags","blobs_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/languages","stargazers_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/stargazers","contributors_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/contributors","subscribers_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/subscribers","subscription_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/subscription","commits_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/contents/{+path}","compare_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/merges","archive_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/downloads","issues_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/issues{/number}","pulls_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/labels{/name}","releases_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/releases{/id}","deployments_url":"https://api.github.com/repos/aurrelhebert/warp10-platform/deployments","created_at":"2016-03-07T15:21:46Z","updated_at":"2016-03-07T15:21:48Z","pushed_at":"2016-08-22T07:56:00Z","git_url":"git://github.com/aurrelhebert/warp10-platform.git","ssh_url":"git@github.com:aurrelhebert/warp10-platform.git","clone_url":"https://github.com/aurrelhebert/warp10-platform.git","svn_url":"https://github.com/aurrelhebert/warp10-platform","homepage":null,"size":1011,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cityzendata:master","ref":"master","sha":"d8b6b0d07d4bbe9a4adc3a38e81ffafe9f524a2c","user":{"login":"cityzendata","id":4659114,"avatar_url":"https://avatars.githubusercontent.com/u/4659114?v=3","gravatar_id":"","url":"https://api.github.com/users/cityzendata","html_url":"https://github.com/cityzendata","followers_url":"https://api.github.com/users/cityzendata/followers","following_url":"https://api.github.com/users/cityzendata/following{/other_user}","gists_url":"https://api.github.com/users/cityzendata/gists{/gist_id}","starred_url":"https://api.github.com/users/cityzendata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cityzendata/subscriptions","organizations_url":"https://api.github.com/users/cityzendata/orgs","repos_url":"https://api.github.com/users/cityzendata/repos","events_url":"https://api.github.com/users/cityzendata/events{/privacy}","received_events_url":"https://api.github.com/users/cityzendata/received_events","type":"User","site_admin":false},"repo":{"id":50594316,"name":"warp10-platform","full_name":"cityzendata/warp10-platform","owner":{"login":"cityzendata","id":4659114,"avatar_url":"https://avatars.githubusercontent.com/u/4659114?v=3","gravatar_id":"","url":"https://api.github.com/users/cityzendata","html_url":"https://github.com/cityzendata","followers_url":"https://api.github.com/users/cityzendata/followers","following_url":"https://api.github.com/users/cityzendata/following{/other_user}","gists_url":"https://api.github.com/users/cityzendata/gists{/gist_id}","starred_url":"https://api.github.com/users/cityzendata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cityzendata/subscriptions","organizations_url":"https://api.github.com/users/cityzendata/orgs","repos_url":"https://api.github.com/users/cityzendata/repos","events_url":"https://api.github.com/users/cityzendata/events{/privacy}","received_events_url":"https://api.github.com/users/cityzendata/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cityzendata/warp10-platform","description":"","fork":false,"url":"https://api.github.com/repos/cityzendata/warp10-platform","forks_url":"https://api.github.com/repos/cityzendata/warp10-platform/forks","keys_url":"https://api.github.com/repos/cityzendata/warp10-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cityzendata/warp10-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cityzendata/warp10-platform/teams","hooks_url":"https://api.github.com/repos/cityzendata/warp10-platform/hooks","issue_events_url":"https://api.github.com/repos/cityzendata/warp10-platform/issues/events{/number}","events_url":"https://api.github.com/repos/cityzendata/warp10-platform/events","assignees_url":"https://api.github.com/repos/cityzendata/warp10-platform/assignees{/user}","branches_url":"https://api.github.com/repos/cityzendata/warp10-platform/branches{/branch}","tags_url":"https://api.github.com/repos/cityzendata/warp10-platform/tags","blobs_url":"https://api.github.com/repos/cityzendata/warp10-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cityzendata/warp10-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cityzendata/warp10-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/cityzendata/warp10-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cityzendata/warp10-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/cityzendata/warp10-platform/languages","stargazers_url":"https://api.github.com/repos/cityzendata/warp10-platform/stargazers","contributors_url":"https://api.github.com/repos/cityzendata/warp10-platform/contributors","subscribers_url":"https://api.github.com/repos/cityzendata/warp10-platform/subscribers","subscription_url":"https://api.github.com/repos/cityzendata/warp10-platform/subscription","commits_url":"https://api.github.com/repos/cityzendata/warp10-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/cityzendata/warp10-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/cityzendata/warp10-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/cityzendata/warp10-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/cityzendata/warp10-platform/contents/{+path}","compare_url":"https://api.github.com/repos/cityzendata/warp10-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cityzendata/warp10-platform/merges","archive_url":"https://api.github.com/repos/cityzendata/warp10-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cityzendata/warp10-platform/downloads","issues_url":"https://api.github.com/repos/cityzendata/warp10-platform/issues{/number}","pulls_url":"https://api.github.com/repos/cityzendata/warp10-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/cityzendata/warp10-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/cityzendata/warp10-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cityzendata/warp10-platform/labels{/name}","releases_url":"https://api.github.com/repos/cityzendata/warp10-platform/releases{/id}","deployments_url":"https://api.github.com/repos/cityzendata/warp10-platform/deployments","created_at":"2016-01-28T15:56:55Z","updated_at":"2016-08-18T09:32:08Z","pushed_at":"2016-08-22T07:58:02Z","git_url":"git://github.com/cityzendata/warp10-platform.git","ssh_url":"git@github.com:cityzendata/warp10-platform.git","clone_url":"https://github.com/cityzendata/warp10-platform.git","svn_url":"https://github.com/cityzendata/warp10-platform","homepage":null,"size":1541,"stargazers_count":29,"watchers_count":29,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":4,"forks":16,"open_issues":4,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79"},"html":{"href":"https://github.com/cityzendata/warp10-platform/pull/79"},"issue":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/issues/79"},"comments":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/issues/79/comments"},"review_comments":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79/comments"},"review_comment":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/pulls/79/commits"},"statuses":{"href":"https://api.github.com/repos/cityzendata/warp10-platform/statuses/53cf3878e2f1ae7d585b281089dcec50d4875274"}}}}
{"actor":{"display_login":"hbs"}}