{"action":"created","comment":{"url":"https://api.github.com/repos/uwescience/myria/pulls/comments/26721370","id":26721370,"diff_hunk":"@@ -0,0 +1,124 @@\n+package edu.washington.escience.myria.operator;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+import java.util.regex.Pattern;\n+\n+import com.google.common.base.Preconditions;\n+import com.google.common.base.Throwables;\n+import com.google.common.collect.ImmutableMap;\n+\n+import edu.washington.escience.myria.DbException;\n+import edu.washington.escience.myria.Schema;\n+import edu.washington.escience.myria.Type;\n+import edu.washington.escience.myria.column.Column;\n+import edu.washington.escience.myria.column.builder.ColumnBuilder;\n+import edu.washington.escience.myria.column.builder.ColumnFactory;\n+import edu.washington.escience.myria.storage.TupleBatch;\n+import edu.washington.escience.myria.storage.TupleBatchBuffer;\n+import edu.washington.escience.myria.storage.TupleUtils;\n+\n+/**\n+ * Operator which splits a string-valued column on a Java regular expression and duplicates the input row with each\n+ * segment of the split result.\n+ * \n+ * E.g., (1, 2, \"foo:bar:baz\") -> (1, 2, \"foo\"), (1, 2, \"bar\"), (1, 2, \"baz\")\n+ */\n+public class Split extends UnaryOperator {\n+  /***/\n+  private static final long serialVersionUID = 1L;\n+\n+  /**\n+   * Index of (string-valued) column to split on regex.\n+   */\n+  private final int splitColumnIndex;\n+\n+  /**\n+   * Compiled regex to split input tuples.\n+   */\n+  private final Pattern pattern;\n+\n+  /**\n+   * Schema of output tuples.\n+   */\n+  private Schema outputSchema;\n+\n+  /**\n+   * Buffer to hold finished and in-progress TupleBatches.\n+   */\n+  private TupleBatchBuffer outputBuffer;\n+\n+  /**\n+   * \n+   * @param child child operator that data is fetched from\n+   * @param columnName name of string column to split using regex\n+   * @param regex regular expression to split string input column on\n+   */\n+  public Split(final Operator child, final int splitColumnIndex, final String regex) {\n+    super(child);\n+    this.splitColumnIndex = splitColumnIndex;\n+    pattern = Pattern.compile(regex);\n+  }\n+\n+  private TupleBatch getChildBatch() throws DbException {\n+    TupleBatch childTuples;\n+    try {\n+      childTuples = getChild().fetchNextReady();\n+    } catch (Exception e) {\n+      // only wrap checked exceptions that do not extend DbException\n+      Throwables.propagateIfPossible(e, DbException.class);\n+      throw new DbException(e);\n+    }\n+    return childTuples;\n+  }","path":"src/edu/washington/escience/myria/operator/Split.java","position":74,"original_position":74,"commit_id":"c2dd4f6ad506dd3bc44f9c89b03c749d257a0afb","original_commit_id":"c2dd4f6ad506dd3bc44f9c89b03c749d257a0afb","user":{"login":"senderista","id":131425,"avatar_url":"https://avatars.githubusercontent.com/u/131425?v=3","gravatar_id":"","url":"https://api.github.com/users/senderista","html_url":"https://github.com/senderista","followers_url":"https://api.github.com/users/senderista/followers","following_url":"https://api.github.com/users/senderista/following{/other_user}","gists_url":"https://api.github.com/users/senderista/gists{/gist_id}","starred_url":"https://api.github.com/users/senderista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senderista/subscriptions","organizations_url":"https://api.github.com/users/senderista/orgs","repos_url":"https://api.github.com/users/senderista/repos","events_url":"https://api.github.com/users/senderista/events{/privacy}","received_events_url":"https://api.github.com/users/senderista/received_events","type":"User","site_admin":false},"body":"Right, calling `nextReady()` instead of `fetchNextReady()` avoids any need for explicit exception handling (and for this helper method).","created_at":"2015-03-19T00:31:21Z","updated_at":"2015-03-19T00:31:21Z","html_url":"https://github.com/uwescience/myria/pull/722#discussion_r26721370","pull_request_url":"https://api.github.com/repos/uwescience/myria/pulls/722","_links":{"self":{"href":"https://api.github.com/repos/uwescience/myria/pulls/comments/26721370"},"html":{"href":"https://github.com/uwescience/myria/pull/722#discussion_r26721370"},"pull_request":{"href":"https://api.github.com/repos/uwescience/myria/pulls/722"}}},"pull_request":{"url":"https://api.github.com/repos/uwescience/myria/pulls/722","id":31087368,"html_url":"https://github.com/uwescience/myria/pull/722","diff_url":"https://github.com/uwescience/myria/pull/722.diff","patch_url":"https://github.com/uwescience/myria/pull/722.patch","issue_url":"https://api.github.com/repos/uwescience/myria/issues/722","number":722,"state":"open","locked":false,"title":"New string split operator.","user":{"login":"senderista","id":131425,"avatar_url":"https://avatars.githubusercontent.com/u/131425?v=3","gravatar_id":"","url":"https://api.github.com/users/senderista","html_url":"https://github.com/senderista","followers_url":"https://api.github.com/users/senderista/followers","following_url":"https://api.github.com/users/senderista/following{/other_user}","gists_url":"https://api.github.com/users/senderista/gists{/gist_id}","starred_url":"https://api.github.com/users/senderista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senderista/subscriptions","organizations_url":"https://api.github.com/users/senderista/orgs","repos_url":"https://api.github.com/users/senderista/repos","events_url":"https://api.github.com/users/senderista/events{/privacy}","received_events_url":"https://api.github.com/users/senderista/received_events","type":"User","site_admin":false},"body":"Some rather arbitrary choices of convention: column to be split (there can be only one) is specified in operator constructor by name rather than by ordinal, column to be split is deleted from output schema, column containing split results is appended to output schema (with name \"_splits\" since I couldn't specify a null or empty string). Basic tests added, but more cases might be desirable.\r\n\r\nNote that this is just a first pass; the final implementation will likely be something like an expression that is evaluated by a generic multi-row-output apply operator. Also multi-column splits are possible (where we would take cartesian product of all results).\r\n","created_at":"2015-03-12T23:18:06Z","updated_at":"2015-03-19T00:31:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66f7452c3031a6735e50b35181ac38b2168814cb","assignee":{"login":"dhalperi","id":526415,"avatar_url":"https://avatars.githubusercontent.com/u/526415?v=3","gravatar_id":"","url":"https://api.github.com/users/dhalperi","html_url":"https://github.com/dhalperi","followers_url":"https://api.github.com/users/dhalperi/followers","following_url":"https://api.github.com/users/dhalperi/following{/other_user}","gists_url":"https://api.github.com/users/dhalperi/gists{/gist_id}","starred_url":"https://api.github.com/users/dhalperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhalperi/subscriptions","organizations_url":"https://api.github.com/users/dhalperi/orgs","repos_url":"https://api.github.com/users/dhalperi/repos","events_url":"https://api.github.com/users/dhalperi/events{/privacy}","received_events_url":"https://api.github.com/users/dhalperi/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/uwescience/myria/pulls/722/commits","review_comments_url":"https://api.github.com/repos/uwescience/myria/pulls/722/comments","review_comment_url":"https://api.github.com/repos/uwescience/myria/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uwescience/myria/issues/722/comments","statuses_url":"https://api.github.com/repos/uwescience/myria/statuses/c2dd4f6ad506dd3bc44f9c89b03c749d257a0afb","head":{"label":"uwescience:mod_op","ref":"mod_op","sha":"c2dd4f6ad506dd3bc44f9c89b03c749d257a0afb","user":{"login":"uwescience","id":2243113,"avatar_url":"https://avatars.githubusercontent.com/u/2243113?v=3","gravatar_id":"","url":"https://api.github.com/users/uwescience","html_url":"https://github.com/uwescience","followers_url":"https://api.github.com/users/uwescience/followers","following_url":"https://api.github.com/users/uwescience/following{/other_user}","gists_url":"https://api.github.com/users/uwescience/gists{/gist_id}","starred_url":"https://api.github.com/users/uwescience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwescience/subscriptions","organizations_url":"https://api.github.com/users/uwescience/orgs","repos_url":"https://api.github.com/users/uwescience/repos","events_url":"https://api.github.com/users/uwescience/events{/privacy}","received_events_url":"https://api.github.com/users/uwescience/received_events","type":"Organization","site_admin":false},"repo":{"id":5612317,"name":"myria","full_name":"uwescience/myria","owner":{"login":"uwescience","id":2243113,"avatar_url":"https://avatars.githubusercontent.com/u/2243113?v=3","gravatar_id":"","url":"https://api.github.com/users/uwescience","html_url":"https://github.com/uwescience","followers_url":"https://api.github.com/users/uwescience/followers","following_url":"https://api.github.com/users/uwescience/following{/other_user}","gists_url":"https://api.github.com/users/uwescience/gists{/gist_id}","starred_url":"https://api.github.com/users/uwescience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwescience/subscriptions","organizations_url":"https://api.github.com/users/uwescience/orgs","repos_url":"https://api.github.com/users/uwescience/repos","events_url":"https://api.github.com/users/uwescience/events{/privacy}","received_events_url":"https://api.github.com/users/uwescience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uwescience/myria","description":"Myria is a scalable Analytics-as-a-Service platform based on relational algebra.","fork":false,"url":"https://api.github.com/repos/uwescience/myria","forks_url":"https://api.github.com/repos/uwescience/myria/forks","keys_url":"https://api.github.com/repos/uwescience/myria/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uwescience/myria/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uwescience/myria/teams","hooks_url":"https://api.github.com/repos/uwescience/myria/hooks","issue_events_url":"https://api.github.com/repos/uwescience/myria/issues/events{/number}","events_url":"https://api.github.com/repos/uwescience/myria/events","assignees_url":"https://api.github.com/repos/uwescience/myria/assignees{/user}","branches_url":"https://api.github.com/repos/uwescience/myria/branches{/branch}","tags_url":"https://api.github.com/repos/uwescience/myria/tags","blobs_url":"https://api.github.com/repos/uwescience/myria/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uwescience/myria/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uwescience/myria/git/refs{/sha}","trees_url":"https://api.github.com/repos/uwescience/myria/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uwescience/myria/statuses/{sha}","languages_url":"https://api.github.com/repos/uwescience/myria/languages","stargazers_url":"https://api.github.com/repos/uwescience/myria/stargazers","contributors_url":"https://api.github.com/repos/uwescience/myria/contributors","subscribers_url":"https://api.github.com/repos/uwescience/myria/subscribers","subscription_url":"https://api.github.com/repos/uwescience/myria/subscription","commits_url":"https://api.github.com/repos/uwescience/myria/commits{/sha}","git_commits_url":"https://api.github.com/repos/uwescience/myria/git/commits{/sha}","comments_url":"https://api.github.com/repos/uwescience/myria/comments{/number}","issue_comment_url":"https://api.github.com/repos/uwescience/myria/issues/comments{/number}","contents_url":"https://api.github.com/repos/uwescience/myria/contents/{+path}","compare_url":"https://api.github.com/repos/uwescience/myria/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uwescience/myria/merges","archive_url":"https://api.github.com/repos/uwescience/myria/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uwescience/myria/downloads","issues_url":"https://api.github.com/repos/uwescience/myria/issues{/number}","pulls_url":"https://api.github.com/repos/uwescience/myria/pulls{/number}","milestones_url":"https://api.github.com/repos/uwescience/myria/milestones{/number}","notifications_url":"https://api.github.com/repos/uwescience/myria/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uwescience/myria/labels{/name}","releases_url":"https://api.github.com/repos/uwescience/myria/releases{/id}","created_at":"2012-08-30T08:27:36Z","updated_at":"2015-03-15T20:42:43Z","pushed_at":"2015-03-17T21:19:46Z","git_url":"git://github.com/uwescience/myria.git","ssh_url":"git@github.com:uwescience/myria.git","clone_url":"https://github.com/uwescience/myria.git","svn_url":"https://github.com/uwescience/myria","homepage":"myria.cs.washington.edu","size":90999,"stargazers_count":15,"watchers_count":15,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":64,"forks":12,"open_issues":64,"watchers":15,"default_branch":"master"}},"base":{"label":"uwescience:master","ref":"master","sha":"0f9675260444e91caf8826f857f8657021ce472b","user":{"login":"uwescience","id":2243113,"avatar_url":"https://avatars.githubusercontent.com/u/2243113?v=3","gravatar_id":"","url":"https://api.github.com/users/uwescience","html_url":"https://github.com/uwescience","followers_url":"https://api.github.com/users/uwescience/followers","following_url":"https://api.github.com/users/uwescience/following{/other_user}","gists_url":"https://api.github.com/users/uwescience/gists{/gist_id}","starred_url":"https://api.github.com/users/uwescience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwescience/subscriptions","organizations_url":"https://api.github.com/users/uwescience/orgs","repos_url":"https://api.github.com/users/uwescience/repos","events_url":"https://api.github.com/users/uwescience/events{/privacy}","received_events_url":"https://api.github.com/users/uwescience/received_events","type":"Organization","site_admin":false},"repo":{"id":5612317,"name":"myria","full_name":"uwescience/myria","owner":{"login":"uwescience","id":2243113,"avatar_url":"https://avatars.githubusercontent.com/u/2243113?v=3","gravatar_id":"","url":"https://api.github.com/users/uwescience","html_url":"https://github.com/uwescience","followers_url":"https://api.github.com/users/uwescience/followers","following_url":"https://api.github.com/users/uwescience/following{/other_user}","gists_url":"https://api.github.com/users/uwescience/gists{/gist_id}","starred_url":"https://api.github.com/users/uwescience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwescience/subscriptions","organizations_url":"https://api.github.com/users/uwescience/orgs","repos_url":"https://api.github.com/users/uwescience/repos","events_url":"https://api.github.com/users/uwescience/events{/privacy}","received_events_url":"https://api.github.com/users/uwescience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uwescience/myria","description":"Myria is a scalable Analytics-as-a-Service platform based on relational algebra.","fork":false,"url":"https://api.github.com/repos/uwescience/myria","forks_url":"https://api.github.com/repos/uwescience/myria/forks","keys_url":"https://api.github.com/repos/uwescience/myria/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uwescience/myria/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uwescience/myria/teams","hooks_url":"https://api.github.com/repos/uwescience/myria/hooks","issue_events_url":"https://api.github.com/repos/uwescience/myria/issues/events{/number}","events_url":"https://api.github.com/repos/uwescience/myria/events","assignees_url":"https://api.github.com/repos/uwescience/myria/assignees{/user}","branches_url":"https://api.github.com/repos/uwescience/myria/branches{/branch}","tags_url":"https://api.github.com/repos/uwescience/myria/tags","blobs_url":"https://api.github.com/repos/uwescience/myria/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uwescience/myria/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uwescience/myria/git/refs{/sha}","trees_url":"https://api.github.com/repos/uwescience/myria/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uwescience/myria/statuses/{sha}","languages_url":"https://api.github.com/repos/uwescience/myria/languages","stargazers_url":"https://api.github.com/repos/uwescience/myria/stargazers","contributors_url":"https://api.github.com/repos/uwescience/myria/contributors","subscribers_url":"https://api.github.com/repos/uwescience/myria/subscribers","subscription_url":"https://api.github.com/repos/uwescience/myria/subscription","commits_url":"https://api.github.com/repos/uwescience/myria/commits{/sha}","git_commits_url":"https://api.github.com/repos/uwescience/myria/git/commits{/sha}","comments_url":"https://api.github.com/repos/uwescience/myria/comments{/number}","issue_comment_url":"https://api.github.com/repos/uwescience/myria/issues/comments{/number}","contents_url":"https://api.github.com/repos/uwescience/myria/contents/{+path}","compare_url":"https://api.github.com/repos/uwescience/myria/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uwescience/myria/merges","archive_url":"https://api.github.com/repos/uwescience/myria/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uwescience/myria/downloads","issues_url":"https://api.github.com/repos/uwescience/myria/issues{/number}","pulls_url":"https://api.github.com/repos/uwescience/myria/pulls{/number}","milestones_url":"https://api.github.com/repos/uwescience/myria/milestones{/number}","notifications_url":"https://api.github.com/repos/uwescience/myria/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uwescience/myria/labels{/name}","releases_url":"https://api.github.com/repos/uwescience/myria/releases{/id}","created_at":"2012-08-30T08:27:36Z","updated_at":"2015-03-15T20:42:43Z","pushed_at":"2015-03-17T21:19:46Z","git_url":"git://github.com/uwescience/myria.git","ssh_url":"git@github.com:uwescience/myria.git","clone_url":"https://github.com/uwescience/myria.git","svn_url":"https://github.com/uwescience/myria","homepage":"myria.cs.washington.edu","size":90999,"stargazers_count":15,"watchers_count":15,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":64,"forks":12,"open_issues":64,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uwescience/myria/pulls/722"},"html":{"href":"https://github.com/uwescience/myria/pull/722"},"issue":{"href":"https://api.github.com/repos/uwescience/myria/issues/722"},"comments":{"href":"https://api.github.com/repos/uwescience/myria/issues/722/comments"},"review_comments":{"href":"https://api.github.com/repos/uwescience/myria/pulls/722/comments"},"review_comment":{"href":"https://api.github.com/repos/uwescience/myria/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uwescience/myria/pulls/722/commits"},"statuses":{"href":"https://api.github.com/repos/uwescience/myria/statuses/c2dd4f6ad506dd3bc44f9c89b03c749d257a0afb"}}}}