{"action":"created","comment":{"url":"https://api.github.com/repos/apache/phoenix/pulls/comments/29023429","id":29023429,"diff_hunk":"@@ -0,0 +1,85 @@\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, 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.phoenix.hive;\n+\n+import java.io.IOException;\n+import java.sql.Connection;\n+import java.sql.PreparedStatement;\n+import java.sql.SQLException;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.apache.hadoop.conf.Configuration;\n+import org.apache.hadoop.io.NullWritable;\n+import org.apache.hadoop.mapred.RecordWriter;\n+import org.apache.hadoop.mapred.Reporter;\n+import org.apache.hadoop.mapreduce.lib.db.DBWritable;\n+import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil;\n+\n+public class HivePhoenixRecordWriter<T extends DBWritable> implements RecordWriter<NullWritable, T> {\n+    private static final Log LOG = LogFactory.getLog(HivePhoenixRecordWriter.class);\n+\n+    private long numRecords = 0L;\n+    private final Connection conn;\n+    private final PreparedStatement statement;\n+    private final long batchSize;\n+\n+    public HivePhoenixRecordWriter(Connection conn, Configuration config) throws SQLException {\n+        this.conn = conn;\n+        this.batchSize = PhoenixConfigurationUtil.getBatchSize(config);\n+        String upsertQuery = PhoenixConfigurationUtil.getUpsertStatement(config);\n+        this.statement = this.conn.prepareStatement(upsertQuery);\n+    }\n+\n+    public void write(NullWritable n, T record) throws IOException {\n+        try {\n+            record.write(this.statement);\n+            this.numRecords += 1L;\n+            this.statement.addBatch();\n+\n+            if (this.numRecords % this.batchSize == 0L) {\n+                LOG.info(\"log commit called on a batch of size : \" + this.batchSize);\n+                this.statement.executeBatch();\n+                //this.conn.commit();","path":"phoenix-hive/src/main/java/org/apache/phoenix/hive/HivePhoenixRecordWriter.java","position":58,"original_position":58,"commit_id":"3de9b30e086d29344f3ff9b4e94d865ddd45632f","original_commit_id":"3de9b30e086d29344f3ff9b4e94d865ddd45632f","user":{"login":"mravi","id":143650,"avatar_url":"https://avatars.githubusercontent.com/u/143650?v=3","gravatar_id":"","url":"https://api.github.com/users/mravi","html_url":"https://github.com/mravi","followers_url":"https://api.github.com/users/mravi/followers","following_url":"https://api.github.com/users/mravi/following{/other_user}","gists_url":"https://api.github.com/users/mravi/gists{/gist_id}","starred_url":"https://api.github.com/users/mravi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mravi/subscriptions","organizations_url":"https://api.github.com/users/mravi/orgs","repos_url":"https://api.github.com/users/mravi/repos","events_url":"https://api.github.com/users/mravi/events{/privacy}","received_events_url":"https://api.github.com/users/mravi/received_events","type":"User","site_admin":false},"body":"Can you please uncomment this line to ensure we commit each batch","created_at":"2015-04-24T04:42:52Z","updated_at":"2015-04-24T04:42:52Z","html_url":"https://github.com/apache/phoenix/pull/74#discussion_r29023429","pull_request_url":"https://api.github.com/repos/apache/phoenix/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/apache/phoenix/pulls/comments/29023429"},"html":{"href":"https://github.com/apache/phoenix/pull/74#discussion_r29023429"},"pull_request":{"href":"https://api.github.com/repos/apache/phoenix/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/apache/phoenix/pulls/74","id":33919667,"html_url":"https://github.com/apache/phoenix/pull/74","diff_url":"https://github.com/apache/phoenix/pull/74.diff","patch_url":"https://github.com/apache/phoenix/pull/74.patch","issue_url":"https://api.github.com/repos/apache/phoenix/issues/74","number":74,"state":"open","locked":false,"title":"Phoenix 331- Phoenix-Hive initial commit ","user":{"login":"nmaillard","id":3994146,"avatar_url":"https://avatars.githubusercontent.com/u/3994146?v=3","gravatar_id":"","url":"https://api.github.com/users/nmaillard","html_url":"https://github.com/nmaillard","followers_url":"https://api.github.com/users/nmaillard/followers","following_url":"https://api.github.com/users/nmaillard/following{/other_user}","gists_url":"https://api.github.com/users/nmaillard/gists{/gist_id}","starred_url":"https://api.github.com/users/nmaillard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmaillard/subscriptions","organizations_url":"https://api.github.com/users/nmaillard/orgs","repos_url":"https://api.github.com/users/nmaillard/repos","events_url":"https://api.github.com/users/nmaillard/events{/privacy}","received_events_url":"https://api.github.com/users/nmaillard/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-23T02:40:37Z","updated_at":"2015-04-24T04:42:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a3a9b51952a3cba3e8f5ac9742cb7921b967100","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/phoenix/pulls/74/commits","review_comments_url":"https://api.github.com/repos/apache/phoenix/pulls/74/comments","review_comment_url":"https://api.github.com/repos/apache/phoenix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/phoenix/issues/74/comments","statuses_url":"https://api.github.com/repos/apache/phoenix/statuses/3de9b30e086d29344f3ff9b4e94d865ddd45632f","head":{"label":"nmaillard:PHOENIX-331","ref":"PHOENIX-331","sha":"3de9b30e086d29344f3ff9b4e94d865ddd45632f","user":{"login":"nmaillard","id":3994146,"avatar_url":"https://avatars.githubusercontent.com/u/3994146?v=3","gravatar_id":"","url":"https://api.github.com/users/nmaillard","html_url":"https://github.com/nmaillard","followers_url":"https://api.github.com/users/nmaillard/followers","following_url":"https://api.github.com/users/nmaillard/following{/other_user}","gists_url":"https://api.github.com/users/nmaillard/gists{/gist_id}","starred_url":"https://api.github.com/users/nmaillard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmaillard/subscriptions","organizations_url":"https://api.github.com/users/nmaillard/orgs","repos_url":"https://api.github.com/users/nmaillard/repos","events_url":"https://api.github.com/users/nmaillard/events{/privacy}","received_events_url":"https://api.github.com/users/nmaillard/received_events","type":"User","site_admin":false},"repo":{"id":34423675,"name":"phoenix","full_name":"nmaillard/phoenix","owner":{"login":"nmaillard","id":3994146,"avatar_url":"https://avatars.githubusercontent.com/u/3994146?v=3","gravatar_id":"","url":"https://api.github.com/users/nmaillard","html_url":"https://github.com/nmaillard","followers_url":"https://api.github.com/users/nmaillard/followers","following_url":"https://api.github.com/users/nmaillard/following{/other_user}","gists_url":"https://api.github.com/users/nmaillard/gists{/gist_id}","starred_url":"https://api.github.com/users/nmaillard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmaillard/subscriptions","organizations_url":"https://api.github.com/users/nmaillard/orgs","repos_url":"https://api.github.com/users/nmaillard/repos","events_url":"https://api.github.com/users/nmaillard/events{/privacy}","received_events_url":"https://api.github.com/users/nmaillard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nmaillard/phoenix","description":"Mirror of Apache Phoenix","fork":true,"url":"https://api.github.com/repos/nmaillard/phoenix","forks_url":"https://api.github.com/repos/nmaillard/phoenix/forks","keys_url":"https://api.github.com/repos/nmaillard/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nmaillard/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nmaillard/phoenix/teams","hooks_url":"https://api.github.com/repos/nmaillard/phoenix/hooks","issue_events_url":"https://api.github.com/repos/nmaillard/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/nmaillard/phoenix/events","assignees_url":"https://api.github.com/repos/nmaillard/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/nmaillard/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/nmaillard/phoenix/tags","blobs_url":"https://api.github.com/repos/nmaillard/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nmaillard/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nmaillard/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/nmaillard/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nmaillard/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/nmaillard/phoenix/languages","stargazers_url":"https://api.github.com/repos/nmaillard/phoenix/stargazers","contributors_url":"https://api.github.com/repos/nmaillard/phoenix/contributors","subscribers_url":"https://api.github.com/repos/nmaillard/phoenix/subscribers","subscription_url":"https://api.github.com/repos/nmaillard/phoenix/subscription","commits_url":"https://api.github.com/repos/nmaillard/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/nmaillard/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/nmaillard/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/nmaillard/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/nmaillard/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/nmaillard/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nmaillard/phoenix/merges","archive_url":"https://api.github.com/repos/nmaillard/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nmaillard/phoenix/downloads","issues_url":"https://api.github.com/repos/nmaillard/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/nmaillard/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/nmaillard/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/nmaillard/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nmaillard/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/nmaillard/phoenix/releases{/id}","created_at":"2015-04-23T00:21:33Z","updated_at":"2015-04-23T00:21:38Z","pushed_at":"2015-04-23T02:35:00Z","git_url":"git://github.com/nmaillard/phoenix.git","ssh_url":"git@github.com:nmaillard/phoenix.git","clone_url":"https://github.com/nmaillard/phoenix.git","svn_url":"https://github.com/nmaillard/phoenix","homepage":null,"size":27707,"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":"e18378b6f837d36ffc839d1d4beff096bd8e6c43","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":20473418,"name":"phoenix","full_name":"apache/phoenix","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/phoenix","description":"Mirror of Apache Phoenix","fork":false,"url":"https://api.github.com/repos/apache/phoenix","forks_url":"https://api.github.com/repos/apache/phoenix/forks","keys_url":"https://api.github.com/repos/apache/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/phoenix/teams","hooks_url":"https://api.github.com/repos/apache/phoenix/hooks","issue_events_url":"https://api.github.com/repos/apache/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/apache/phoenix/events","assignees_url":"https://api.github.com/repos/apache/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/apache/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/apache/phoenix/tags","blobs_url":"https://api.github.com/repos/apache/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/phoenix/languages","stargazers_url":"https://api.github.com/repos/apache/phoenix/stargazers","contributors_url":"https://api.github.com/repos/apache/phoenix/contributors","subscribers_url":"https://api.github.com/repos/apache/phoenix/subscribers","subscription_url":"https://api.github.com/repos/apache/phoenix/subscription","commits_url":"https://api.github.com/repos/apache/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/apache/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/phoenix/merges","archive_url":"https://api.github.com/repos/apache/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/phoenix/downloads","issues_url":"https://api.github.com/repos/apache/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/apache/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/apache/phoenix/releases{/id}","created_at":"2014-06-04T07:00:08Z","updated_at":"2015-04-24T02:47:31Z","pushed_at":"2015-04-24T02:47:30Z","git_url":"git://github.com/apache/phoenix.git","ssh_url":"git@github.com:apache/phoenix.git","clone_url":"https://github.com/apache/phoenix.git","svn_url":"https://github.com/apache/phoenix","homepage":null,"size":27707,"stargazers_count":59,"watchers_count":59,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":112,"mirror_url":"git://git.apache.org/phoenix.git","open_issues_count":46,"forks":112,"open_issues":46,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/phoenix/pulls/74"},"html":{"href":"https://github.com/apache/phoenix/pull/74"},"issue":{"href":"https://api.github.com/repos/apache/phoenix/issues/74"},"comments":{"href":"https://api.github.com/repos/apache/phoenix/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/phoenix/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/phoenix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/phoenix/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/apache/phoenix/statuses/3de9b30e086d29344f3ff9b4e94d865ddd45632f"}}}}