{"action":"created","comment":{"url":"https://api.github.com/repos/idibon/java-client/pulls/comments/36599820","id":36599820,"diff_hunk":"@@ -0,0 +1,216 @@\n+package com.idibon;\n+\n+import java.io.*;\n+import java.util.Map;\n+import java.util.stream.*;\n+import java.nio.file.Files;\n+import java.nio.charset.Charset;\n+import java.util.concurrent.atomic.AtomicInteger;\n+\n+import javax.json.JsonObject;\n+\n+import com.idibon.api.http.impl.JdkHttpInterface;\n+import com.idibon.api.model.*;\n+import com.idibon.api.IdibonAPI;\n+import com.idibon.api.util.Either;\n+\n+import org.apache.commons.cli.*;\n+\n+/**\n+ * Iterates through documents in a collection and predicts every document\n+ * against a task in parallel.\n+ *\n+ * Allows for command-line control of the number of parallel connections\n+ * to use, and limiting the number of documents to a subset of the\n+ * entire collection.\n+ */\n+public class BatchPredict {\n+\n+    public static void main(String[] args) throws Exception {\n+        CommandLine options = parseCommandLine(args);\n+        if (options == null) return;\n+\n+        IdibonAPI client = createClient(options);\n+\n+        /* count the number of classification operations performed by this\n+         * application, to build a performance report at the end. */\n+        AtomicInteger predictions = new AtomicInteger(0);\n+        long start = System.currentTimeMillis();\n+\n+        try (Stream<DocumentContent> source = getSourceData(client, options)) {\n+            Task task = getClassificationTask(client, options);\n+\n+            /* classify all of the documents in the source data using a\n+             * lambda forEach expression */\n+            task.classifications(source::iterator).withSignificantFeatures(0.8)","path":"examples/batch-predict/src/main/java/com/idibon/BatchPredict.java","position":45,"original_position":45,"commit_id":"d7575224ba7f4f6a3025ef0f59121866103b8d0f","original_commit_id":"d7575224ba7f4f6a3025ef0f59121866103b8d0f","user":{"login":"skrawcz","id":2328071,"avatar_url":"https://avatars.githubusercontent.com/u/2328071?v=3","gravatar_id":"","url":"https://api.github.com/users/skrawcz","html_url":"https://github.com/skrawcz","followers_url":"https://api.github.com/users/skrawcz/followers","following_url":"https://api.github.com/users/skrawcz/following{/other_user}","gists_url":"https://api.github.com/users/skrawcz/gists{/gist_id}","starred_url":"https://api.github.com/users/skrawcz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skrawcz/subscriptions","organizations_url":"https://api.github.com/users/skrawcz/orgs","repos_url":"https://api.github.com/users/skrawcz/repos","events_url":"https://api.github.com/users/skrawcz/events{/privacy}","received_events_url":"https://api.github.com/users/skrawcz/received_events","type":"User","site_admin":false},"body":"should 0.8 be a constant or a overridable parameter?","created_at":"2015-08-10T03:27:14Z","updated_at":"2015-08-10T03:27:14Z","html_url":"https://github.com/idibon/java-client/pull/16#discussion_r36599820","pull_request_url":"https://api.github.com/repos/idibon/java-client/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/idibon/java-client/pulls/comments/36599820"},"html":{"href":"https://github.com/idibon/java-client/pull/16#discussion_r36599820"},"pull_request":{"href":"https://api.github.com/repos/idibon/java-client/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/idibon/java-client/pulls/16","id":41978517,"html_url":"https://github.com/idibon/java-client/pull/16","diff_url":"https://github.com/idibon/java-client/pull/16.diff","patch_url":"https://github.com/idibon/java-client/pull/16.patch","issue_url":"https://api.github.com/repos/idibon/java-client/issues/16","number":16,"state":"open","locked":false,"title":"add Java 8 batch prediction sample, increase allowed parallelism","user":{"login":"idigary","id":7969111,"avatar_url":"https://avatars.githubusercontent.com/u/7969111?v=3","gravatar_id":"","url":"https://api.github.com/users/idigary","html_url":"https://github.com/idigary","followers_url":"https://api.github.com/users/idigary/followers","following_url":"https://api.github.com/users/idigary/following{/other_user}","gists_url":"https://api.github.com/users/idigary/gists{/gist_id}","starred_url":"https://api.github.com/users/idigary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idigary/subscriptions","organizations_url":"https://api.github.com/users/idigary/orgs","repos_url":"https://api.github.com/users/idigary/repos","events_url":"https://api.github.com/users/idigary/events{/privacy}","received_events_url":"https://api.github.com/users/idigary/received_events","type":"User","site_admin":false},"body":"recent server changes have enabled prediction performance to reasonably scale\r\nbeyond 100 parallel connections, so up the limit in the Java SDK to 1000, and include\r\na custom user agent string for tracking\r\n\r\nadd a new Java 8 sample application demonstrating how to classify lots of content, either\r\nread from lines in a file or search results from the collection","created_at":"2015-08-09T22:43:08Z","updated_at":"2015-08-10T03:27:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ce147255bc6133b3a473d2ff31af8a096cbf9ec","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/idibon/java-client/pulls/16/commits","review_comments_url":"https://api.github.com/repos/idibon/java-client/pulls/16/comments","review_comment_url":"https://api.github.com/repos/idibon/java-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/idibon/java-client/issues/16/comments","statuses_url":"https://api.github.com/repos/idibon/java-client/statuses/d7575224ba7f4f6a3025ef0f59121866103b8d0f","head":{"label":"idibon:batch-prediction-sample","ref":"batch-prediction-sample","sha":"d7575224ba7f4f6a3025ef0f59121866103b8d0f","user":{"login":"idibon","id":2282291,"avatar_url":"https://avatars.githubusercontent.com/u/2282291?v=3","gravatar_id":"","url":"https://api.github.com/users/idibon","html_url":"https://github.com/idibon","followers_url":"https://api.github.com/users/idibon/followers","following_url":"https://api.github.com/users/idibon/following{/other_user}","gists_url":"https://api.github.com/users/idibon/gists{/gist_id}","starred_url":"https://api.github.com/users/idibon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idibon/subscriptions","organizations_url":"https://api.github.com/users/idibon/orgs","repos_url":"https://api.github.com/users/idibon/repos","events_url":"https://api.github.com/users/idibon/events{/privacy}","received_events_url":"https://api.github.com/users/idibon/received_events","type":"Organization","site_admin":false},"repo":{"id":11822015,"name":"java-client","full_name":"idibon/java-client","owner":{"login":"idibon","id":2282291,"avatar_url":"https://avatars.githubusercontent.com/u/2282291?v=3","gravatar_id":"","url":"https://api.github.com/users/idibon","html_url":"https://github.com/idibon","followers_url":"https://api.github.com/users/idibon/followers","following_url":"https://api.github.com/users/idibon/following{/other_user}","gists_url":"https://api.github.com/users/idibon/gists{/gist_id}","starred_url":"https://api.github.com/users/idibon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idibon/subscriptions","organizations_url":"https://api.github.com/users/idibon/orgs","repos_url":"https://api.github.com/users/idibon/repos","events_url":"https://api.github.com/users/idibon/events{/privacy}","received_events_url":"https://api.github.com/users/idibon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/idibon/java-client","description":"Idibon API Java client","fork":false,"url":"https://api.github.com/repos/idibon/java-client","forks_url":"https://api.github.com/repos/idibon/java-client/forks","keys_url":"https://api.github.com/repos/idibon/java-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/idibon/java-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/idibon/java-client/teams","hooks_url":"https://api.github.com/repos/idibon/java-client/hooks","issue_events_url":"https://api.github.com/repos/idibon/java-client/issues/events{/number}","events_url":"https://api.github.com/repos/idibon/java-client/events","assignees_url":"https://api.github.com/repos/idibon/java-client/assignees{/user}","branches_url":"https://api.github.com/repos/idibon/java-client/branches{/branch}","tags_url":"https://api.github.com/repos/idibon/java-client/tags","blobs_url":"https://api.github.com/repos/idibon/java-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/idibon/java-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/idibon/java-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/idibon/java-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/idibon/java-client/statuses/{sha}","languages_url":"https://api.github.com/repos/idibon/java-client/languages","stargazers_url":"https://api.github.com/repos/idibon/java-client/stargazers","contributors_url":"https://api.github.com/repos/idibon/java-client/contributors","subscribers_url":"https://api.github.com/repos/idibon/java-client/subscribers","subscription_url":"https://api.github.com/repos/idibon/java-client/subscription","commits_url":"https://api.github.com/repos/idibon/java-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/idibon/java-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/idibon/java-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/idibon/java-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/idibon/java-client/contents/{+path}","compare_url":"https://api.github.com/repos/idibon/java-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/idibon/java-client/merges","archive_url":"https://api.github.com/repos/idibon/java-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/idibon/java-client/downloads","issues_url":"https://api.github.com/repos/idibon/java-client/issues{/number}","pulls_url":"https://api.github.com/repos/idibon/java-client/pulls{/number}","milestones_url":"https://api.github.com/repos/idibon/java-client/milestones{/number}","notifications_url":"https://api.github.com/repos/idibon/java-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/idibon/java-client/labels{/name}","releases_url":"https://api.github.com/repos/idibon/java-client/releases{/id}","created_at":"2013-08-01T16:37:23Z","updated_at":"2015-06-25T16:13:34Z","pushed_at":"2015-08-09T22:43:08Z","git_url":"git://github.com/idibon/java-client.git","ssh_url":"git@github.com:idibon/java-client.git","clone_url":"https://github.com/idibon/java-client.git","svn_url":"https://github.com/idibon/java-client","homepage":null,"size":847,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"idibon:master","ref":"master","sha":"cbdd4a84a0b079b548f92b9e40a3281029cf7d8c","user":{"login":"idibon","id":2282291,"avatar_url":"https://avatars.githubusercontent.com/u/2282291?v=3","gravatar_id":"","url":"https://api.github.com/users/idibon","html_url":"https://github.com/idibon","followers_url":"https://api.github.com/users/idibon/followers","following_url":"https://api.github.com/users/idibon/following{/other_user}","gists_url":"https://api.github.com/users/idibon/gists{/gist_id}","starred_url":"https://api.github.com/users/idibon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idibon/subscriptions","organizations_url":"https://api.github.com/users/idibon/orgs","repos_url":"https://api.github.com/users/idibon/repos","events_url":"https://api.github.com/users/idibon/events{/privacy}","received_events_url":"https://api.github.com/users/idibon/received_events","type":"Organization","site_admin":false},"repo":{"id":11822015,"name":"java-client","full_name":"idibon/java-client","owner":{"login":"idibon","id":2282291,"avatar_url":"https://avatars.githubusercontent.com/u/2282291?v=3","gravatar_id":"","url":"https://api.github.com/users/idibon","html_url":"https://github.com/idibon","followers_url":"https://api.github.com/users/idibon/followers","following_url":"https://api.github.com/users/idibon/following{/other_user}","gists_url":"https://api.github.com/users/idibon/gists{/gist_id}","starred_url":"https://api.github.com/users/idibon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idibon/subscriptions","organizations_url":"https://api.github.com/users/idibon/orgs","repos_url":"https://api.github.com/users/idibon/repos","events_url":"https://api.github.com/users/idibon/events{/privacy}","received_events_url":"https://api.github.com/users/idibon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/idibon/java-client","description":"Idibon API Java client","fork":false,"url":"https://api.github.com/repos/idibon/java-client","forks_url":"https://api.github.com/repos/idibon/java-client/forks","keys_url":"https://api.github.com/repos/idibon/java-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/idibon/java-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/idibon/java-client/teams","hooks_url":"https://api.github.com/repos/idibon/java-client/hooks","issue_events_url":"https://api.github.com/repos/idibon/java-client/issues/events{/number}","events_url":"https://api.github.com/repos/idibon/java-client/events","assignees_url":"https://api.github.com/repos/idibon/java-client/assignees{/user}","branches_url":"https://api.github.com/repos/idibon/java-client/branches{/branch}","tags_url":"https://api.github.com/repos/idibon/java-client/tags","blobs_url":"https://api.github.com/repos/idibon/java-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/idibon/java-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/idibon/java-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/idibon/java-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/idibon/java-client/statuses/{sha}","languages_url":"https://api.github.com/repos/idibon/java-client/languages","stargazers_url":"https://api.github.com/repos/idibon/java-client/stargazers","contributors_url":"https://api.github.com/repos/idibon/java-client/contributors","subscribers_url":"https://api.github.com/repos/idibon/java-client/subscribers","subscription_url":"https://api.github.com/repos/idibon/java-client/subscription","commits_url":"https://api.github.com/repos/idibon/java-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/idibon/java-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/idibon/java-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/idibon/java-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/idibon/java-client/contents/{+path}","compare_url":"https://api.github.com/repos/idibon/java-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/idibon/java-client/merges","archive_url":"https://api.github.com/repos/idibon/java-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/idibon/java-client/downloads","issues_url":"https://api.github.com/repos/idibon/java-client/issues{/number}","pulls_url":"https://api.github.com/repos/idibon/java-client/pulls{/number}","milestones_url":"https://api.github.com/repos/idibon/java-client/milestones{/number}","notifications_url":"https://api.github.com/repos/idibon/java-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/idibon/java-client/labels{/name}","releases_url":"https://api.github.com/repos/idibon/java-client/releases{/id}","created_at":"2013-08-01T16:37:23Z","updated_at":"2015-06-25T16:13:34Z","pushed_at":"2015-08-09T22:43:08Z","git_url":"git://github.com/idibon/java-client.git","ssh_url":"git@github.com:idibon/java-client.git","clone_url":"https://github.com/idibon/java-client.git","svn_url":"https://github.com/idibon/java-client","homepage":null,"size":847,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/idibon/java-client/pulls/16"},"html":{"href":"https://github.com/idibon/java-client/pull/16"},"issue":{"href":"https://api.github.com/repos/idibon/java-client/issues/16"},"comments":{"href":"https://api.github.com/repos/idibon/java-client/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/idibon/java-client/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/idibon/java-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/idibon/java-client/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/idibon/java-client/statuses/d7575224ba7f4f6a3025ef0f59121866103b8d0f"}}}}