{"action":"created","comment":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/74970039","id":74970039,"diff_hunk":"@@ -0,0 +1,130 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package com.datatorrent.lib.streamquery.function;\n+\n+import com.datatorrent.api.DefaultInputPort;\n+import com.datatorrent.api.DefaultOutputPort;\n+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;\n+import com.datatorrent.common.util.BaseOperator;\n+\n+import java.util.ArrayList;\n+\n+/**\n+ * An implementation of function NVL which lets you substitute a value when a null\n+ * value is encountered.\n+ *\n+ * The syntax for NVL function is:\n+ *      NVL (orig_string, replace_with)\n+ *      orig_string: the string to test for a NULL value\n+ *      replace_with: the value returned if orig_string is null.\n+ *      (Note the function will return orig_string if it is not null)\n+ *\n+ * For example, with the following table\n+ *\n+ *      EMP table\n+ *      ========\n+ *      name   salary\n+ *      ----------------\n+ *      mike   1000\n+ *      ben    null\n+ *      dave   1500\n+ *      SELECT NVL(salary, 0) FROM emp WHERE name='ben' will return 0.\n+ *      SELECT NVL(salary, 0) FROM emp WHERE name='dave' will return 1500.\n+ *\n+ * @displayName NVL Function\n+ * @category Stream Manipulators\n+ * @tags sql nvl\n+ * @since 0.3.4\n+ */\n+public class NvlFunction<T> extends BaseOperator\n+{\n+    /**\n+     * Array to store column inputs during window.\n+     */\n+    private ArrayList<T> columns = new ArrayList<T>();\n+\n+    /**\n+     * Array to store aliases input during window.\n+     */\n+    private ArrayList<T> aliases = new ArrayList<T>();\n+\n+    /**\n+     * Number of input pairs processed in current window.\n+     */\n+    private int index = 0;\n+\n+    /**\n+     * Column input port\n+     */\n+    public final transient DefaultInputPort<T> column = new DefaultInputPort<T>()\n+    {\n+        @Override\n+        public void process(T tuple) {\n+            columns.add(tuple);\n+            if (aliases.size() > index) {\n+                int loc = aliases.size();\n+                if (loc > columns.size()) {\n+                    loc = columns.size();\n+                }\n+                emit(columns.get(loc - 1), aliases.get(loc - 1));\n+                index++;\n+            }","path":"library/src/main/java/com/datatorrent/lib/streamquery/function/NvlFunction.java","position":87,"original_position":87,"commit_id":"cca82caeabbd0d936744950b75c641369f75bd23","original_commit_id":"cca82caeabbd0d936744950b75c641369f75bd23","user":{"login":"d9liang","id":10467200,"avatar_url":"https://avatars.githubusercontent.com/u/10467200?v=3","gravatar_id":"","url":"https://api.github.com/users/d9liang","html_url":"https://github.com/d9liang","followers_url":"https://api.github.com/users/d9liang/followers","following_url":"https://api.github.com/users/d9liang/following{/other_user}","gists_url":"https://api.github.com/users/d9liang/gists{/gist_id}","starred_url":"https://api.github.com/users/d9liang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d9liang/subscriptions","organizations_url":"https://api.github.com/users/d9liang/orgs","repos_url":"https://api.github.com/users/d9liang/repos","events_url":"https://api.github.com/users/d9liang/events{/privacy}","received_events_url":"https://api.github.com/users/d9liang/received_events","type":"User","site_admin":false},"body":"Will add a common function for that","created_at":"2016-08-16T16:29:02Z","updated_at":"2016-08-16T16:29:02Z","html_url":"https://github.com/apache/apex-malhar/pull/371#discussion_r74970039","pull_request_url":"https://api.github.com/repos/apache/apex-malhar/pulls/371","_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/74970039"},"html":{"href":"https://github.com/apache/apex-malhar/pull/371#discussion_r74970039"},"pull_request":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/371"}}},"pull_request":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/371","id":81390695,"html_url":"https://github.com/apache/apex-malhar/pull/371","diff_url":"https://github.com/apache/apex-malhar/pull/371.diff","patch_url":"https://github.com/apache/apex-malhar/pull/371.patch","issue_url":"https://api.github.com/repos/apache/apex-malhar/issues/371","number":371,"state":"open","locked":false,"title":"APEXMALHAR-1815 Support NVL function","user":{"login":"d9liang","id":10467200,"avatar_url":"https://avatars.githubusercontent.com/u/10467200?v=3","gravatar_id":"","url":"https://api.github.com/users/d9liang","html_url":"https://github.com/d9liang","followers_url":"https://api.github.com/users/d9liang/followers","following_url":"https://api.github.com/users/d9liang/following{/other_user}","gists_url":"https://api.github.com/users/d9liang/gists{/gist_id}","starred_url":"https://api.github.com/users/d9liang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d9liang/subscriptions","organizations_url":"https://api.github.com/users/d9liang/orgs","repos_url":"https://api.github.com/users/d9liang/repos","events_url":"https://api.github.com/users/d9liang/events{/privacy}","received_events_url":"https://api.github.com/users/d9liang/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-15T23:06:33Z","updated_at":"2016-08-16T16:29:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6f5585f92963438d7103027ad8784205a0c7195c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/apex-malhar/pulls/371/commits","review_comments_url":"https://api.github.com/repos/apache/apex-malhar/pulls/371/comments","review_comment_url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/apex-malhar/issues/371/comments","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/cca82caeabbd0d936744950b75c641369f75bd23","head":{"label":"d9liang:MLHR-1815","ref":"MLHR-1815","sha":"cca82caeabbd0d936744950b75c641369f75bd23","user":{"login":"d9liang","id":10467200,"avatar_url":"https://avatars.githubusercontent.com/u/10467200?v=3","gravatar_id":"","url":"https://api.github.com/users/d9liang","html_url":"https://github.com/d9liang","followers_url":"https://api.github.com/users/d9liang/followers","following_url":"https://api.github.com/users/d9liang/following{/other_user}","gists_url":"https://api.github.com/users/d9liang/gists{/gist_id}","starred_url":"https://api.github.com/users/d9liang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d9liang/subscriptions","organizations_url":"https://api.github.com/users/d9liang/orgs","repos_url":"https://api.github.com/users/d9liang/repos","events_url":"https://api.github.com/users/d9liang/events{/privacy}","received_events_url":"https://api.github.com/users/d9liang/received_events","type":"User","site_admin":false},"repo":{"id":62154078,"name":"apex-malhar","full_name":"d9liang/apex-malhar","owner":{"login":"d9liang","id":10467200,"avatar_url":"https://avatars.githubusercontent.com/u/10467200?v=3","gravatar_id":"","url":"https://api.github.com/users/d9liang","html_url":"https://github.com/d9liang","followers_url":"https://api.github.com/users/d9liang/followers","following_url":"https://api.github.com/users/d9liang/following{/other_user}","gists_url":"https://api.github.com/users/d9liang/gists{/gist_id}","starred_url":"https://api.github.com/users/d9liang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d9liang/subscriptions","organizations_url":"https://api.github.com/users/d9liang/orgs","repos_url":"https://api.github.com/users/d9liang/repos","events_url":"https://api.github.com/users/d9liang/events{/privacy}","received_events_url":"https://api.github.com/users/d9liang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/d9liang/apex-malhar","description":"Mirror of Apache Apex malhar","fork":true,"url":"https://api.github.com/repos/d9liang/apex-malhar","forks_url":"https://api.github.com/repos/d9liang/apex-malhar/forks","keys_url":"https://api.github.com/repos/d9liang/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/d9liang/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/d9liang/apex-malhar/teams","hooks_url":"https://api.github.com/repos/d9liang/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/d9liang/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/d9liang/apex-malhar/events","assignees_url":"https://api.github.com/repos/d9liang/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/d9liang/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/d9liang/apex-malhar/tags","blobs_url":"https://api.github.com/repos/d9liang/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/d9liang/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/d9liang/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/d9liang/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/d9liang/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/d9liang/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/d9liang/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/d9liang/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/d9liang/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/d9liang/apex-malhar/subscription","commits_url":"https://api.github.com/repos/d9liang/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/d9liang/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/d9liang/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/d9liang/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/d9liang/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/d9liang/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/d9liang/apex-malhar/merges","archive_url":"https://api.github.com/repos/d9liang/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/d9liang/apex-malhar/downloads","issues_url":"https://api.github.com/repos/d9liang/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/d9liang/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/d9liang/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/d9liang/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/d9liang/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/d9liang/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/d9liang/apex-malhar/deployments","created_at":"2016-06-28T15:46:23Z","updated_at":"2016-06-28T15:46:29Z","pushed_at":"2016-08-15T23:05:40Z","git_url":"git://github.com/d9liang/apex-malhar.git","ssh_url":"git@github.com:d9liang/apex-malhar.git","clone_url":"https://github.com/d9liang/apex-malhar.git","svn_url":"https://github.com/d9liang/apex-malhar","homepage":"","size":86104,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"9b6e11d85accc88faa08d7b4a8daeb9b069fc878","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":41348334,"name":"apex-malhar","full_name":"apache/apex-malhar","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/apex-malhar","description":"Mirror of Apache Apex malhar","fork":false,"url":"https://api.github.com/repos/apache/apex-malhar","forks_url":"https://api.github.com/repos/apache/apex-malhar/forks","keys_url":"https://api.github.com/repos/apache/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/apex-malhar/teams","hooks_url":"https://api.github.com/repos/apache/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/apache/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/apache/apex-malhar/events","assignees_url":"https://api.github.com/repos/apache/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/apache/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/apache/apex-malhar/tags","blobs_url":"https://api.github.com/repos/apache/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/apache/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/apache/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/apache/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/apache/apex-malhar/subscription","commits_url":"https://api.github.com/repos/apache/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/apache/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/apex-malhar/merges","archive_url":"https://api.github.com/repos/apache/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/apex-malhar/downloads","issues_url":"https://api.github.com/repos/apache/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/apache/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/apache/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/apache/apex-malhar/deployments","created_at":"2015-08-25T07:00:05Z","updated_at":"2016-08-16T15:18:39Z","pushed_at":"2016-08-16T13:05:44Z","git_url":"git://github.com/apache/apex-malhar.git","ssh_url":"git@github.com:apache/apex-malhar.git","clone_url":"https://github.com/apache/apex-malhar.git","svn_url":"https://github.com/apache/apex-malhar","homepage":"","size":97475,"stargazers_count":55,"watchers_count":55,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":95,"mirror_url":"git://git.apache.org/incubator-apex-malhar.git","open_issues_count":29,"forks":95,"open_issues":29,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/371"},"html":{"href":"https://github.com/apache/apex-malhar/pull/371"},"issue":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/371"},"comments":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/371/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/371/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/371/commits"},"statuses":{"href":"https://api.github.com/repos/apache/apex-malhar/statuses/cca82caeabbd0d936744950b75c641369f75bd23"}}}}
{"actor":{"display_login":"d9liang"}}