{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/74700122","id":74700122,"diff_hunk":"@@ -0,0 +1,69 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * 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, 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+package org.apache.flink.streaming.util.serialization;\n+\n+import com.fasterxml.jackson.databind.JsonNode;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import com.fasterxml.jackson.databind.node.ObjectNode;\n+import org.apache.flink.api.table.Row;\n+import org.apache.flink.util.Preconditions;\n+\n+\n+/**\n+ * Serialization schema that serializes an object into a JSON bytes.\n+ *\n+ * <p>Serializes the input {@link Row} object into a JSON string and\n+ * converts it into <code>byte[]</code>.\n+ *\n+ * <p>Result <bode>byte[]</bode> messages can be deserialized using\n+ * {@link JsonRowDeserializationSchema}.\n+ */\n+public class JsonRowSerializationSchema implements SerializationSchema<Row> {\n+\t/** Fields names in the input Row object */\n+\tprivate final String[] fieldNames;\n+\t/** Object mapper that is used to create output JSON objects */\n+\tprivate static ObjectMapper mapper = new ObjectMapper();\n+\n+\t/**\n+\t * Creates a JSON serialization schema for the given fields and types.\n+\t *\n+\t * @param fieldNames Names of JSON fields to parse.\n+\t */\n+\tpublic JsonRowSerializationSchema(String[] fieldNames) {\n+\t\tthis.fieldNames = Preconditions.checkNotNull(fieldNames);\n+\t}\n+\n+\t@Override\n+\tpublic byte[] serialize(Row row) {\n+\t\tif (row.productArity() != fieldNames.length) {\n+\t\t\tthrow new IllegalStateException(String.format(\n+\t\t\t\t\"Number of elements in the row %s is different from number of field names: %d\", row, fieldNames.length));\n+\t\t}\n+\n+\t\tObjectNode objectNode = mapper.createObjectNode();\n+\t\tfor (int i = 0; i < row.productArity(); i++) {\n+\t\t\tJsonNode node = mapper.valueToTree(row.productElement(i));\n+\t\t\tobjectNode.set(fieldNames[i], node);\n+\t\t}\n+\n+\t\ttry {\n+\t\t\treturn mapper.writeValueAsBytes(objectNode);\n+\t\t} catch (Exception e) {\n+\t\t\tthrow new RuntimeException(\"Failed to serialize row\", e);","path":"flink-streaming-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/util/serialization/JsonRowSerializationSchema.java","position":66,"original_position":66,"commit_id":"7dc770ac23790acfb585eb1b66bbb01000b1adaf","original_commit_id":"7dc770ac23790acfb585eb1b66bbb01000b1adaf","user":{"login":"wuchong","id":5378924,"avatar_url":"https://avatars.githubusercontent.com/u/5378924?v=3","gravatar_id":"","url":"https://api.github.com/users/wuchong","html_url":"https://github.com/wuchong","followers_url":"https://api.github.com/users/wuchong/followers","following_url":"https://api.github.com/users/wuchong/following{/other_user}","gists_url":"https://api.github.com/users/wuchong/gists{/gist_id}","starred_url":"https://api.github.com/users/wuchong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wuchong/subscriptions","organizations_url":"https://api.github.com/users/wuchong/orgs","repos_url":"https://api.github.com/users/wuchong/repos","events_url":"https://api.github.com/users/wuchong/events{/privacy}","received_events_url":"https://api.github.com/users/wuchong/received_events","type":"User","site_admin":false},"body":"BTW, it seems that change the interface will not break japicmp check. Maybe we can change it , I'm not sure.   \r\n\r\n@twalthr @aljoscha what do you think? ","created_at":"2016-08-14T11:23:59Z","updated_at":"2016-08-14T11:23:59Z","html_url":"https://github.com/apache/flink/pull/2244#discussion_r74700122","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/2244","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/74700122"},"html":{"href":"https://github.com/apache/flink/pull/2244#discussion_r74700122"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/2244"}}},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/2244","id":77367261,"html_url":"https://github.com/apache/flink/pull/2244","diff_url":"https://github.com/apache/flink/pull/2244.diff","patch_url":"https://github.com/apache/flink/pull/2244.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/2244","number":2244,"state":"open","locked":false,"title":"[FLINK-3874]  Add a Kafka TableSink with JSON serialization","user":{"login":"mushketyk","id":592286,"avatar_url":"https://avatars.githubusercontent.com/u/592286?v=3","gravatar_id":"","url":"https://api.github.com/users/mushketyk","html_url":"https://github.com/mushketyk","followers_url":"https://api.github.com/users/mushketyk/followers","following_url":"https://api.github.com/users/mushketyk/following{/other_user}","gists_url":"https://api.github.com/users/mushketyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mushketyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mushketyk/subscriptions","organizations_url":"https://api.github.com/users/mushketyk/orgs","repos_url":"https://api.github.com/users/mushketyk/repos","events_url":"https://api.github.com/users/mushketyk/events{/privacy}","received_events_url":"https://api.github.com/users/mushketyk/received_events","type":"User","site_admin":false},"body":"Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.\r\nIf your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html).\r\nIn addition to going through the list, please provide a meaningful description of your changes.\r\n\r\n- [x] General\r\n  - The pull request references the related JIRA issue (\"[FLINK-XXX] Jira title text\")\r\n  - The pull request addresses only one issue\r\n  - Each commit in the PR has a meaningful commit message (including the JIRA id)\r\n\r\n- [x] Documentation\r\n  - Documentation has been added for new functionality\r\n  - Old documentation affected by the pull request has been updated\r\n  - JavaDoc for public methods has been added\r\n\r\n- [x] Tests & Build\r\n  - Functionality added by the pull request is covered by tests\r\n  - `mvn clean verify` has been executed successfully locally or a Travis build has passed\r\n","created_at":"2016-07-13T21:45:21Z","updated_at":"2016-08-14T11:23:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13290828d0e764f8600ebcb698e167475af72574","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/2244/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/2244/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/flink/issues/2244/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/7dc770ac23790acfb585eb1b66bbb01000b1adaf","head":{"label":"mushketyk:kafka-json","ref":"kafka-json","sha":"7dc770ac23790acfb585eb1b66bbb01000b1adaf","user":{"login":"mushketyk","id":592286,"avatar_url":"https://avatars.githubusercontent.com/u/592286?v=3","gravatar_id":"","url":"https://api.github.com/users/mushketyk","html_url":"https://github.com/mushketyk","followers_url":"https://api.github.com/users/mushketyk/followers","following_url":"https://api.github.com/users/mushketyk/following{/other_user}","gists_url":"https://api.github.com/users/mushketyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mushketyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mushketyk/subscriptions","organizations_url":"https://api.github.com/users/mushketyk/orgs","repos_url":"https://api.github.com/users/mushketyk/repos","events_url":"https://api.github.com/users/mushketyk/events{/privacy}","received_events_url":"https://api.github.com/users/mushketyk/received_events","type":"User","site_admin":false},"repo":{"id":61241085,"name":"flink","full_name":"mushketyk/flink","owner":{"login":"mushketyk","id":592286,"avatar_url":"https://avatars.githubusercontent.com/u/592286?v=3","gravatar_id":"","url":"https://api.github.com/users/mushketyk","html_url":"https://github.com/mushketyk","followers_url":"https://api.github.com/users/mushketyk/followers","following_url":"https://api.github.com/users/mushketyk/following{/other_user}","gists_url":"https://api.github.com/users/mushketyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mushketyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mushketyk/subscriptions","organizations_url":"https://api.github.com/users/mushketyk/orgs","repos_url":"https://api.github.com/users/mushketyk/repos","events_url":"https://api.github.com/users/mushketyk/events{/privacy}","received_events_url":"https://api.github.com/users/mushketyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mushketyk/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/mushketyk/flink","forks_url":"https://api.github.com/repos/mushketyk/flink/forks","keys_url":"https://api.github.com/repos/mushketyk/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mushketyk/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mushketyk/flink/teams","hooks_url":"https://api.github.com/repos/mushketyk/flink/hooks","issue_events_url":"https://api.github.com/repos/mushketyk/flink/issues/events{/number}","events_url":"https://api.github.com/repos/mushketyk/flink/events","assignees_url":"https://api.github.com/repos/mushketyk/flink/assignees{/user}","branches_url":"https://api.github.com/repos/mushketyk/flink/branches{/branch}","tags_url":"https://api.github.com/repos/mushketyk/flink/tags","blobs_url":"https://api.github.com/repos/mushketyk/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mushketyk/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mushketyk/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/mushketyk/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mushketyk/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/mushketyk/flink/languages","stargazers_url":"https://api.github.com/repos/mushketyk/flink/stargazers","contributors_url":"https://api.github.com/repos/mushketyk/flink/contributors","subscribers_url":"https://api.github.com/repos/mushketyk/flink/subscribers","subscription_url":"https://api.github.com/repos/mushketyk/flink/subscription","commits_url":"https://api.github.com/repos/mushketyk/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/mushketyk/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/mushketyk/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/mushketyk/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/mushketyk/flink/contents/{+path}","compare_url":"https://api.github.com/repos/mushketyk/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mushketyk/flink/merges","archive_url":"https://api.github.com/repos/mushketyk/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mushketyk/flink/downloads","issues_url":"https://api.github.com/repos/mushketyk/flink/issues{/number}","pulls_url":"https://api.github.com/repos/mushketyk/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/mushketyk/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/mushketyk/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mushketyk/flink/labels{/name}","releases_url":"https://api.github.com/repos/mushketyk/flink/releases{/id}","deployments_url":"https://api.github.com/repos/mushketyk/flink/deployments","created_at":"2016-06-15T21:08:43Z","updated_at":"2016-06-15T21:09:09Z","pushed_at":"2016-08-13T22:50:26Z","git_url":"git://github.com/mushketyk/flink.git","ssh_url":"git@github.com:mushketyk/flink.git","clone_url":"https://github.com/mushketyk/flink.git","svn_url":"https://github.com/mushketyk/flink","homepage":null,"size":89740,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"b71ac354d19dccdd8bfa837b92f6bc814c9d29c6","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":20587599,"name":"flink","full_name":"apache/flink","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/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","deployments_url":"https://api.github.com/repos/apache/flink/deployments","created_at":"2014-06-07T07:00:10Z","updated_at":"2016-08-12T20:52:53Z","pushed_at":"2016-08-14T00:18:23Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":119974,"stargazers_count":1500,"watchers_count":1500,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":991,"mirror_url":"git://git.apache.org/flink.git","open_issues_count":129,"forks":991,"open_issues":129,"watchers":1500,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/2244"},"html":{"href":"https://github.com/apache/flink/pull/2244"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/2244"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/2244/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/2244/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/2244/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/7dc770ac23790acfb585eb1b66bbb01000b1adaf"}}}}
{"actor":{"display_login":"wuchong"}}