{"action":"created","comment":{"url":"https://api.github.com/repos/apache/metron/pulls/comments/275822862","pull_request_review_id":227226397,"id":275822862,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI3NTgyMjg2Mg==","diff_hunk":"@@ -82,4 +83,67 @@ public Object apply(List<Object> objects) {\n       return ret;\n     }\n   }\n+\n+  @Stellar(name = \"PUT\",\n+           namespace = \"MAP\",\n+           description = \"Adds a key/value pair to a map\",\n+           params = {\n+                      \"key - The key\",\n+                      \"value - The value\",\n+                      \"map - The map to perform the put on\"\n+                    },\n+           returns = \"The original map modified with the key/value. If the map argument is null, a new map will be created and returned that contains the provided key and value - note: if the 'map' argument is null, only the returned map will be non-null and contain the key/value.\"\n+          )\n+  public static class MapPut extends BaseStellarFunction {\n+\n+    @Override\n+    @SuppressWarnings(\"unchecked\")\n+    public Object apply(List<Object> objects) {\n+      if (objects.size() < 3) {\n+        throw new IllegalArgumentException(\"Must pass a key, value, and map\");\n+      } else {\n+        Object keyObj = objects.get(0);\n+        Object valueObj = objects.get(1);\n+        Object mapObj = objects.get(2);\n+        if (mapObj == null) {\n+          mapObj = new HashMap<>();\n+        }\n+        Map<Object, Object> map = (Map) mapObj;\n+        map.put(keyObj, valueObj);\n+        return map;\n+      }\n+    }\n+  }\n+\n+  @Stellar(name = \"MERGE\",\n+           namespace = \"MAP\",\n+           description = \"Merges a list of maps\",\n+           params = {\"maps - A collection of maps to merge\"},\n+           returns = \"A Map. null if the list of maps is empty.\"\n+          )\n+  public static class MapMerge extends BaseStellarFunction {\n+\n+    @Override\n+    @SuppressWarnings(\"unchecked\")\n+    public Object apply(List<Object> list) {\n+      if (list.size() < 1) {\n+        return null;\n+      }\n+      LinkedHashMap<Object, Object> ret = new LinkedHashMap<>();\n+      Object o = list.get(0);\n+      if (o != null) {\n+        if (!(o instanceof Iterable)) {\n+          throw new IllegalArgumentException(\"Expected an Iterable, but \" + o + \" is of type \" + o.getClass());\n+        }\n+        Iterable<? extends Map> maps = (Iterable<? extends Map>) o;","path":"metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MapFunctions.java","position":97,"original_position":97,"commit_id":"a0715074645ce4ae9611adfda3b62001089ea5d7","original_commit_id":"a0715074645ce4ae9611adfda3b62001089ea5d7","user":{"login":"mmiklavc","id":658443,"node_id":"MDQ6VXNlcjY1ODQ0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/658443?v=4","gravatar_id":"","url":"https://api.github.com/users/mmiklavc","html_url":"https://github.com/mmiklavc","followers_url":"https://api.github.com/users/mmiklavc/followers","following_url":"https://api.github.com/users/mmiklavc/following{/other_user}","gists_url":"https://api.github.com/users/mmiklavc/gists{/gist_id}","starred_url":"https://api.github.com/users/mmiklavc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmiklavc/subscriptions","organizations_url":"https://api.github.com/users/mmiklavc/orgs","repos_url":"https://api.github.com/users/mmiklavc/repos","events_url":"https://api.github.com/users/mmiklavc/events{/privacy}","received_events_url":"https://api.github.com/users/mmiklavc/received_events","type":"User","site_admin":false},"body":"Hey @cestella, thanks for the review! I'm not sure I completely follow - `getFirst` also requires a default. I initialize the return value on line 132, but it's outside of the `if` block. Maybe you meant `if (Iterables.size(maps) == 1){ return Iterables.getFirst(maps);)`?\r\n\r\nSide note, I had initially wanted to use `Iterables.addAll()` for consistency , however this only accepts `Collections`, which the `Map` interface does not extend. https://github.com/apache/metron/blob/master/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/SetFunctions.java#L137","created_at":"2019-04-16T14:20:23Z","updated_at":"2019-04-16T14:20:23Z","html_url":"https://github.com/apache/metron/pull/1385#discussion_r275822862","pull_request_url":"https://api.github.com/repos/apache/metron/pulls/1385","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/metron/pulls/comments/275822862"},"html":{"href":"https://github.com/apache/metron/pull/1385#discussion_r275822862"},"pull_request":{"href":"https://api.github.com/repos/apache/metron/pulls/1385"}},"in_reply_to_id":275782059},"pull_request":{"url":"https://api.github.com/repos/apache/metron/pulls/1385","id":270648543,"node_id":"MDExOlB1bGxSZXF1ZXN0MjcwNjQ4NTQz","html_url":"https://github.com/apache/metron/pull/1385","diff_url":"https://github.com/apache/metron/pull/1385.diff","patch_url":"https://github.com/apache/metron/pull/1385.patch","issue_url":"https://api.github.com/repos/apache/metron/issues/1385","number":1385,"state":"open","locked":false,"title":"METRON-2071 Add MAP_PUT and MAP_MERGE to Stellar","user":{"login":"mmiklavc","id":658443,"node_id":"MDQ6VXNlcjY1ODQ0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/658443?v=4","gravatar_id":"","url":"https://api.github.com/users/mmiklavc","html_url":"https://github.com/mmiklavc","followers_url":"https://api.github.com/users/mmiklavc/followers","following_url":"https://api.github.com/users/mmiklavc/following{/other_user}","gists_url":"https://api.github.com/users/mmiklavc/gists{/gist_id}","starred_url":"https://api.github.com/users/mmiklavc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmiklavc/subscriptions","organizations_url":"https://api.github.com/users/mmiklavc/orgs","repos_url":"https://api.github.com/users/mmiklavc/repos","events_url":"https://api.github.com/users/mmiklavc/events{/privacy}","received_events_url":"https://api.github.com/users/mmiklavc/received_events","type":"User","site_admin":false},"body":"## Contributor Comments\r\n\r\nhttps://issues.apache.org/jira/browse/METRON-2071\r\n\r\nAdds 2 new functions, MAP_PUT and MAP_MERGE, to Stellar. I had originally looked at MAP_PUT alone, and when reviewing some of the other data type features such as Sets and Multisets, MAP_MERGE also seemed like a reasonable addition.\r\n\r\n**Testing**\r\n\r\nI've added pretty extensive unit tests for this, and there are no new dependencies outside of core Java, so I believe manual testing would be optional for this change. If you wish to perform manual validation, spin up full dev (or the Stellar shell in stand-alone mode locally, see https://github.com/apache/metron/tree/master/metron-stellar/stellar-common#stellar-shell-stand-alone) and run through the expressions in the new unit tests for MAP_PUT and MAP_MERGE.\r\n\r\n## Pull Request Checklist\r\n\r\n### For all changes:\r\n- [x] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).\r\n- [x] Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen \"-\" character.\r\n- [x] Has your PR been rebased against the latest commit within the target branch (typically master)?\r\n\r\n\r\n### For code changes:\r\n- [x] Have you included steps to reproduce the behavior or problem that is being changed or addressed?\r\n- [x] Have you included steps or a guide to how the change may be verified and tested manually?\r\n- [x] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:\r\n  ```\r\n  mvn -q clean integration-test install && dev-utilities/build-utils/verify_licenses.sh \r\n  ```\r\n\r\n- [x] Have you written or updated unit tests and or integration tests to verify your changes?\r\n- n/a If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?\r\n- n/a Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?\r\n\r\n### For documentation related changes:\r\n- [x] Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via `site-book/target/site/index.html`:\r\n\r\n  ```\r\n  cd site-book\r\n  mvn site\r\n  ```\r\n","created_at":"2019-04-15T19:47:34Z","updated_at":"2019-04-16T14:20:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e2318ced3dec437fa4bf37786ff4688322d59de","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/metron/pulls/1385/commits","review_comments_url":"https://api.github.com/repos/apache/metron/pulls/1385/comments","review_comment_url":"https://api.github.com/repos/apache/metron/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/metron/issues/1385/comments","statuses_url":"https://api.github.com/repos/apache/metron/statuses/a0715074645ce4ae9611adfda3b62001089ea5d7","head":{"label":"mmiklavc:METRON-2071","ref":"METRON-2071","sha":"a0715074645ce4ae9611adfda3b62001089ea5d7","user":{"login":"mmiklavc","id":658443,"node_id":"MDQ6VXNlcjY1ODQ0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/658443?v=4","gravatar_id":"","url":"https://api.github.com/users/mmiklavc","html_url":"https://github.com/mmiklavc","followers_url":"https://api.github.com/users/mmiklavc/followers","following_url":"https://api.github.com/users/mmiklavc/following{/other_user}","gists_url":"https://api.github.com/users/mmiklavc/gists{/gist_id}","starred_url":"https://api.github.com/users/mmiklavc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmiklavc/subscriptions","organizations_url":"https://api.github.com/users/mmiklavc/orgs","repos_url":"https://api.github.com/users/mmiklavc/repos","events_url":"https://api.github.com/users/mmiklavc/events{/privacy}","received_events_url":"https://api.github.com/users/mmiklavc/received_events","type":"User","site_admin":false},"repo":{"id":58224042,"node_id":"MDEwOlJlcG9zaXRvcnk1ODIyNDA0Mg==","name":"metron","full_name":"mmiklavc/metron","private":false,"owner":{"login":"mmiklavc","id":658443,"node_id":"MDQ6VXNlcjY1ODQ0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/658443?v=4","gravatar_id":"","url":"https://api.github.com/users/mmiklavc","html_url":"https://github.com/mmiklavc","followers_url":"https://api.github.com/users/mmiklavc/followers","following_url":"https://api.github.com/users/mmiklavc/following{/other_user}","gists_url":"https://api.github.com/users/mmiklavc/gists{/gist_id}","starred_url":"https://api.github.com/users/mmiklavc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmiklavc/subscriptions","organizations_url":"https://api.github.com/users/mmiklavc/orgs","repos_url":"https://api.github.com/users/mmiklavc/repos","events_url":"https://api.github.com/users/mmiklavc/events{/privacy}","received_events_url":"https://api.github.com/users/mmiklavc/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mmiklavc/metron","description":"Mirror of Apache Metron","fork":true,"url":"https://api.github.com/repos/mmiklavc/metron","forks_url":"https://api.github.com/repos/mmiklavc/metron/forks","keys_url":"https://api.github.com/repos/mmiklavc/metron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mmiklavc/metron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mmiklavc/metron/teams","hooks_url":"https://api.github.com/repos/mmiklavc/metron/hooks","issue_events_url":"https://api.github.com/repos/mmiklavc/metron/issues/events{/number}","events_url":"https://api.github.com/repos/mmiklavc/metron/events","assignees_url":"https://api.github.com/repos/mmiklavc/metron/assignees{/user}","branches_url":"https://api.github.com/repos/mmiklavc/metron/branches{/branch}","tags_url":"https://api.github.com/repos/mmiklavc/metron/tags","blobs_url":"https://api.github.com/repos/mmiklavc/metron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mmiklavc/metron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mmiklavc/metron/git/refs{/sha}","trees_url":"https://api.github.com/repos/mmiklavc/metron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mmiklavc/metron/statuses/{sha}","languages_url":"https://api.github.com/repos/mmiklavc/metron/languages","stargazers_url":"https://api.github.com/repos/mmiklavc/metron/stargazers","contributors_url":"https://api.github.com/repos/mmiklavc/metron/contributors","subscribers_url":"https://api.github.com/repos/mmiklavc/metron/subscribers","subscription_url":"https://api.github.com/repos/mmiklavc/metron/subscription","commits_url":"https://api.github.com/repos/mmiklavc/metron/commits{/sha}","git_commits_url":"https://api.github.com/repos/mmiklavc/metron/git/commits{/sha}","comments_url":"https://api.github.com/repos/mmiklavc/metron/comments{/number}","issue_comment_url":"https://api.github.com/repos/mmiklavc/metron/issues/comments{/number}","contents_url":"https://api.github.com/repos/mmiklavc/metron/contents/{+path}","compare_url":"https://api.github.com/repos/mmiklavc/metron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mmiklavc/metron/merges","archive_url":"https://api.github.com/repos/mmiklavc/metron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mmiklavc/metron/downloads","issues_url":"https://api.github.com/repos/mmiklavc/metron/issues{/number}","pulls_url":"https://api.github.com/repos/mmiklavc/metron/pulls{/number}","milestones_url":"https://api.github.com/repos/mmiklavc/metron/milestones{/number}","notifications_url":"https://api.github.com/repos/mmiklavc/metron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mmiklavc/metron/labels{/name}","releases_url":"https://api.github.com/repos/mmiklavc/metron/releases{/id}","deployments_url":"https://api.github.com/repos/mmiklavc/metron/deployments","created_at":"2016-05-06T17:35:02Z","updated_at":"2019-04-15T21:45:12Z","pushed_at":"2019-04-15T21:45:10Z","git_url":"git://github.com/mmiklavc/metron.git","ssh_url":"git@github.com:mmiklavc/metron.git","clone_url":"https://github.com/mmiklavc/metron.git","svn_url":"https://github.com/mmiklavc/metron","homepage":"","size":97409,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"57095488f28a017e290e021fea65412e7240e8da","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":47607561,"node_id":"MDEwOlJlcG9zaXRvcnk0NzYwNzU2MQ==","name":"metron","full_name":"apache/metron","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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},"html_url":"https://github.com/apache/metron","description":"Apache Metron","fork":false,"url":"https://api.github.com/repos/apache/metron","forks_url":"https://api.github.com/repos/apache/metron/forks","keys_url":"https://api.github.com/repos/apache/metron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/metron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/metron/teams","hooks_url":"https://api.github.com/repos/apache/metron/hooks","issue_events_url":"https://api.github.com/repos/apache/metron/issues/events{/number}","events_url":"https://api.github.com/repos/apache/metron/events","assignees_url":"https://api.github.com/repos/apache/metron/assignees{/user}","branches_url":"https://api.github.com/repos/apache/metron/branches{/branch}","tags_url":"https://api.github.com/repos/apache/metron/tags","blobs_url":"https://api.github.com/repos/apache/metron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/metron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/metron/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/metron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/metron/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/metron/languages","stargazers_url":"https://api.github.com/repos/apache/metron/stargazers","contributors_url":"https://api.github.com/repos/apache/metron/contributors","subscribers_url":"https://api.github.com/repos/apache/metron/subscribers","subscription_url":"https://api.github.com/repos/apache/metron/subscription","commits_url":"https://api.github.com/repos/apache/metron/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/metron/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/metron/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/metron/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/metron/contents/{+path}","compare_url":"https://api.github.com/repos/apache/metron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/metron/merges","archive_url":"https://api.github.com/repos/apache/metron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/metron/downloads","issues_url":"https://api.github.com/repos/apache/metron/issues{/number}","pulls_url":"https://api.github.com/repos/apache/metron/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/metron/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/metron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/metron/labels{/name}","releases_url":"https://api.github.com/repos/apache/metron/releases{/id}","deployments_url":"https://api.github.com/repos/apache/metron/deployments","created_at":"2015-12-08T08:00:05Z","updated_at":"2019-04-15T21:41:16Z","pushed_at":"2019-04-16T11:56:21Z","git_url":"git://github.com/apache/metron.git","ssh_url":"git@github.com:apache/metron.git","clone_url":"https://github.com/apache/metron.git","svn_url":"https://github.com/apache/metron","homepage":"","size":94311,"stargazers_count":606,"watchers_count":606,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":430,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":430,"open_issues":32,"watchers":606,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/metron/pulls/1385"},"html":{"href":"https://github.com/apache/metron/pull/1385"},"issue":{"href":"https://api.github.com/repos/apache/metron/issues/1385"},"comments":{"href":"https://api.github.com/repos/apache/metron/issues/1385/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/metron/pulls/1385/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/metron/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/metron/pulls/1385/commits"},"statuses":{"href":"https://api.github.com/repos/apache/metron/statuses/a0715074645ce4ae9611adfda3b62001089ea5d7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mmiklavc"}}