{"action":"created","comment":{"url":"https://api.github.com/repos/apache/arrow/pulls/comments/223609577","pull_request_review_id":162772746,"id":223609577,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzYwOTU3Nw==","diff_hunk":"@@ -96,23 +97,31 @@ int RecordBatch__to_file(const std::shared_ptr<arrow::RecordBatch>& batch,\n }\n \n // [[Rcpp::export]]\n-RawVector RecordBatch__to_raw(const std::shared_ptr<arrow::RecordBatch>& batch) {\n-  MemoryPool* pool = default_memory_pool();\n+RawVector RecordBatch__to_stream(const std::shared_ptr<arrow::RecordBatch>& batch) {\n+  std::unique_ptr<io::MockOutputStream> mockSink;\n+  mockSink.reset(new io::MockOutputStream());\n \n-  std::shared_ptr<ResizableBuffer> buffer;\n-  R_ERROR_NOT_OK(AllocateResizableBuffer(pool, 0, &buffer));\n+  std::shared_ptr<arrow::ipc::RecordBatchWriter> mockWriter;\n+  R_ERROR_NOT_OK(arrow::ipc::RecordBatchStreamWriter::Open(mockSink.get(),\n+                                                           batch->schema(),\n+                                                           &mockWriter));\n \n-  std::unique_ptr<io::BufferOutputStream> sink;\n-  sink.reset(new io::BufferOutputStream(buffer));\n+  R_ERROR_NOT_OK(mockWriter->WriteRecordBatch(*batch));\n+  R_ERROR_NOT_OK(mockWriter->Close());\n+\n+  RawVector res(mockSink->GetExtentBytesWritten());\n+\n+  std::unique_ptr<RawVectorOutputStream> sink;\n+  sink.reset(new RawVectorOutputStream(res));\n \n   std::shared_ptr<arrow::ipc::RecordBatchWriter> writer;\n-  R_ERROR_NOT_OK(arrow::ipc::RecordBatchStreamWriter::Open(sink.get(), batch->schema(), &writer));\n+  R_ERROR_NOT_OK(arrow::ipc::RecordBatchStreamWriter::Open(sink.get(),\n+                                                           batch->schema(),\n+                                                           &writer));\n \n   R_ERROR_NOT_OK(writer->WriteRecordBatch(*batch));\n   R_ERROR_NOT_OK(writer->Close());","path":"r/src/RecordBatch.cpp","position":40,"original_position":42,"commit_id":"ec1a8c2fe924f347f3fe492afb98a92414d5c34d","original_commit_id":"a1580df0df5c3333766b4779cb93271ea7f9984e","user":{"login":"wesm","id":329591,"node_id":"MDQ6VXNlcjMyOTU5MQ==","avatar_url":"https://avatars2.githubusercontent.com/u/329591?v=4","gravatar_id":"","url":"https://api.github.com/users/wesm","html_url":"https://github.com/wesm","followers_url":"https://api.github.com/users/wesm/followers","following_url":"https://api.github.com/users/wesm/following{/other_user}","gists_url":"https://api.github.com/users/wesm/gists{/gist_id}","starred_url":"https://api.github.com/users/wesm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wesm/subscriptions","organizations_url":"https://api.github.com/users/wesm/orgs","repos_url":"https://api.github.com/users/wesm/repos","events_url":"https://api.github.com/users/wesm/events{/privacy}","received_events_url":"https://api.github.com/users/wesm/received_events","type":"User","site_admin":false},"body":"Ditto","created_at":"2018-10-09T08:47:28Z","updated_at":"2018-10-09T08:47:44Z","html_url":"https://github.com/apache/arrow/pull/2727#discussion_r223609577","pull_request_url":"https://api.github.com/repos/apache/arrow/pulls/2727","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apache/arrow/pulls/comments/223609577"},"html":{"href":"https://github.com/apache/arrow/pull/2727#discussion_r223609577"},"pull_request":{"href":"https://api.github.com/repos/apache/arrow/pulls/2727"}}},"pull_request":{"url":"https://api.github.com/repos/apache/arrow/pulls/2727","id":221205575,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxMjA1NTc1","html_url":"https://github.com/apache/arrow/pull/2727","diff_url":"https://github.com/apache/arrow/pull/2727.diff","patch_url":"https://github.com/apache/arrow/pull/2727.patch","issue_url":"https://api.github.com/repos/apache/arrow/issues/2727","number":2727,"state":"open","locked":false,"title":"[WIP] Improvements to support R to Spark in socket serialization","user":{"login":"javierluraschi","id":3478847,"node_id":"MDQ6VXNlcjM0Nzg4NDc=","avatar_url":"https://avatars1.githubusercontent.com/u/3478847?v=4","gravatar_id":"","url":"https://api.github.com/users/javierluraschi","html_url":"https://github.com/javierluraschi","followers_url":"https://api.github.com/users/javierluraschi/followers","following_url":"https://api.github.com/users/javierluraschi/following{/other_user}","gists_url":"https://api.github.com/users/javierluraschi/gists{/gist_id}","starred_url":"https://api.github.com/users/javierluraschi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierluraschi/subscriptions","organizations_url":"https://api.github.com/users/javierluraschi/orgs","repos_url":"https://api.github.com/users/javierluraschi/repos","events_url":"https://api.github.com/users/javierluraschi/events{/privacy}","received_events_url":"https://api.github.com/users/javierluraschi/received_events","type":"User","site_admin":false},"body":"Using this PR as a WIP to efficiently transfer data from R to Spark using Arrow.\r\n\r\nThis PR might be ultimately closed and not merged, but thought it would be good to give visibility as to what I'm exploring.\r\n\r\nSpecifically, I'm working on supporting efficient execution of:\r\n\r\n```r\r\nlibrary(sparklyr)\r\nsc <- spark_connect(master = \"local\")\r\ncopy_to(sc, system.time({\r\n\ttbl_data <- sdf_copy_to(sc, data.frame(y = runif(10^6, 0, 1)), \"data\", overwrite = TRUE)\r\n})\r\n```\r\n\r\nCurrently, without this PR at nor Arrow:\r\n\r\n```r\r\nsystem.time({\r\n  tbl_data <- sdf_copy_to(sc, data.frame(y = runif(10^6, 0, 1)), \"data\", overwrite = TRUE)\r\n})\r\n   user  system elapsed \r\n  1.120   0.087   3.482 \r\n```\r\n\r\nUsing arrow down to:\r\n\r\n```r\r\nlibrary(arrow)\r\ncopy_to(sc, system.time({\r\n  tbl_data <- sdf_copy_to(sc, data.frame(y = runif(10^6, 0, 1)), \"data\", overwrite = TRUE)\r\n})\r\n```\r\n```\r\n   user  system elapsed \r\n  0.222   0.029   0.641 \r\n```\r\n\r\nAnd down to the following while using `std::copy()`\r\n\r\n```\r\n   user  system elapsed \r\n  0.107   0.008   0.388 \r\n```\r\n\r\nCurrently exploring [ALTREP](https://svn.r-project.org/R/branches/ALTREP/ALTREP.html) to avoid `std::copy()`....","created_at":"2018-10-08T18:29:45Z","updated_at":"2018-10-09T08:47:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2254f921cd75a6a496009329a0fc8d910a490672","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/arrow/pulls/2727/commits","review_comments_url":"https://api.github.com/repos/apache/arrow/pulls/2727/comments","review_comment_url":"https://api.github.com/repos/apache/arrow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/arrow/issues/2727/comments","statuses_url":"https://api.github.com/repos/apache/arrow/statuses/ec1a8c2fe924f347f3fe492afb98a92414d5c34d","head":{"label":"javierluraschi:feature/r-to-raw","ref":"feature/r-to-raw","sha":"ec1a8c2fe924f347f3fe492afb98a92414d5c34d","user":{"login":"javierluraschi","id":3478847,"node_id":"MDQ6VXNlcjM0Nzg4NDc=","avatar_url":"https://avatars1.githubusercontent.com/u/3478847?v=4","gravatar_id":"","url":"https://api.github.com/users/javierluraschi","html_url":"https://github.com/javierluraschi","followers_url":"https://api.github.com/users/javierluraschi/followers","following_url":"https://api.github.com/users/javierluraschi/following{/other_user}","gists_url":"https://api.github.com/users/javierluraschi/gists{/gist_id}","starred_url":"https://api.github.com/users/javierluraschi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierluraschi/subscriptions","organizations_url":"https://api.github.com/users/javierluraschi/orgs","repos_url":"https://api.github.com/users/javierluraschi/repos","events_url":"https://api.github.com/users/javierluraschi/events{/privacy}","received_events_url":"https://api.github.com/users/javierluraschi/received_events","type":"User","site_admin":false},"repo":{"id":151864859,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE4NjQ4NTk=","name":"arrow","full_name":"javierluraschi/arrow","private":false,"owner":{"login":"javierluraschi","id":3478847,"node_id":"MDQ6VXNlcjM0Nzg4NDc=","avatar_url":"https://avatars1.githubusercontent.com/u/3478847?v=4","gravatar_id":"","url":"https://api.github.com/users/javierluraschi","html_url":"https://github.com/javierluraschi","followers_url":"https://api.github.com/users/javierluraschi/followers","following_url":"https://api.github.com/users/javierluraschi/following{/other_user}","gists_url":"https://api.github.com/users/javierluraschi/gists{/gist_id}","starred_url":"https://api.github.com/users/javierluraschi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierluraschi/subscriptions","organizations_url":"https://api.github.com/users/javierluraschi/orgs","repos_url":"https://api.github.com/users/javierluraschi/repos","events_url":"https://api.github.com/users/javierluraschi/events{/privacy}","received_events_url":"https://api.github.com/users/javierluraschi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/javierluraschi/arrow","description":"Apache Arrow is a cross-language development platform for in-memory data. It specifies a standardized language-independent columnar memory format for flat and hierarchical data, organized for efficient analytic operations on modern hardware. It also provides computational libraries and zero-copy streaming messaging and interprocess communication. Languages currently supported include C, C++, Java, JavaScript, Python, and Ruby.","fork":true,"url":"https://api.github.com/repos/javierluraschi/arrow","forks_url":"https://api.github.com/repos/javierluraschi/arrow/forks","keys_url":"https://api.github.com/repos/javierluraschi/arrow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javierluraschi/arrow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javierluraschi/arrow/teams","hooks_url":"https://api.github.com/repos/javierluraschi/arrow/hooks","issue_events_url":"https://api.github.com/repos/javierluraschi/arrow/issues/events{/number}","events_url":"https://api.github.com/repos/javierluraschi/arrow/events","assignees_url":"https://api.github.com/repos/javierluraschi/arrow/assignees{/user}","branches_url":"https://api.github.com/repos/javierluraschi/arrow/branches{/branch}","tags_url":"https://api.github.com/repos/javierluraschi/arrow/tags","blobs_url":"https://api.github.com/repos/javierluraschi/arrow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javierluraschi/arrow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javierluraschi/arrow/git/refs{/sha}","trees_url":"https://api.github.com/repos/javierluraschi/arrow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javierluraschi/arrow/statuses/{sha}","languages_url":"https://api.github.com/repos/javierluraschi/arrow/languages","stargazers_url":"https://api.github.com/repos/javierluraschi/arrow/stargazers","contributors_url":"https://api.github.com/repos/javierluraschi/arrow/contributors","subscribers_url":"https://api.github.com/repos/javierluraschi/arrow/subscribers","subscription_url":"https://api.github.com/repos/javierluraschi/arrow/subscription","commits_url":"https://api.github.com/repos/javierluraschi/arrow/commits{/sha}","git_commits_url":"https://api.github.com/repos/javierluraschi/arrow/git/commits{/sha}","comments_url":"https://api.github.com/repos/javierluraschi/arrow/comments{/number}","issue_comment_url":"https://api.github.com/repos/javierluraschi/arrow/issues/comments{/number}","contents_url":"https://api.github.com/repos/javierluraschi/arrow/contents/{+path}","compare_url":"https://api.github.com/repos/javierluraschi/arrow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javierluraschi/arrow/merges","archive_url":"https://api.github.com/repos/javierluraschi/arrow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javierluraschi/arrow/downloads","issues_url":"https://api.github.com/repos/javierluraschi/arrow/issues{/number}","pulls_url":"https://api.github.com/repos/javierluraschi/arrow/pulls{/number}","milestones_url":"https://api.github.com/repos/javierluraschi/arrow/milestones{/number}","notifications_url":"https://api.github.com/repos/javierluraschi/arrow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javierluraschi/arrow/labels{/name}","releases_url":"https://api.github.com/repos/javierluraschi/arrow/releases{/id}","deployments_url":"https://api.github.com/repos/javierluraschi/arrow/deployments","created_at":"2018-10-06T17:32:27Z","updated_at":"2018-10-06T17:32:35Z","pushed_at":"2018-10-09T01:40:54Z","git_url":"git://github.com/javierluraschi/arrow.git","ssh_url":"git@github.com:javierluraschi/arrow.git","clone_url":"https://github.com/javierluraschi/arrow.git","svn_url":"https://github.com/javierluraschi/arrow","homepage":"https://arrow.apache.org","size":19040,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"c951043825bbb19d8ece0e123cd9e5c7ec80f962","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":51905353,"node_id":"MDEwOlJlcG9zaXRvcnk1MTkwNTM1Mw==","name":"arrow","full_name":"apache/arrow","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/arrow","description":"Apache Arrow is a cross-language development platform for in-memory data. It specifies a standardized language-independent columnar memory format for flat and hierarchical data, organized for efficient analytic operations on modern hardware. It also provides computational libraries and zero-copy streaming messaging and interprocess communication. Languages currently supported include C, C++, Java, JavaScript, Python, and Ruby.","fork":false,"url":"https://api.github.com/repos/apache/arrow","forks_url":"https://api.github.com/repos/apache/arrow/forks","keys_url":"https://api.github.com/repos/apache/arrow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/arrow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/arrow/teams","hooks_url":"https://api.github.com/repos/apache/arrow/hooks","issue_events_url":"https://api.github.com/repos/apache/arrow/issues/events{/number}","events_url":"https://api.github.com/repos/apache/arrow/events","assignees_url":"https://api.github.com/repos/apache/arrow/assignees{/user}","branches_url":"https://api.github.com/repos/apache/arrow/branches{/branch}","tags_url":"https://api.github.com/repos/apache/arrow/tags","blobs_url":"https://api.github.com/repos/apache/arrow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/arrow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/arrow/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/arrow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/arrow/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/arrow/languages","stargazers_url":"https://api.github.com/repos/apache/arrow/stargazers","contributors_url":"https://api.github.com/repos/apache/arrow/contributors","subscribers_url":"https://api.github.com/repos/apache/arrow/subscribers","subscription_url":"https://api.github.com/repos/apache/arrow/subscription","commits_url":"https://api.github.com/repos/apache/arrow/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/arrow/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/arrow/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/arrow/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/arrow/contents/{+path}","compare_url":"https://api.github.com/repos/apache/arrow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/arrow/merges","archive_url":"https://api.github.com/repos/apache/arrow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/arrow/downloads","issues_url":"https://api.github.com/repos/apache/arrow/issues{/number}","pulls_url":"https://api.github.com/repos/apache/arrow/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/arrow/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/arrow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/arrow/labels{/name}","releases_url":"https://api.github.com/repos/apache/arrow/releases{/id}","deployments_url":"https://api.github.com/repos/apache/arrow/deployments","created_at":"2016-02-17T08:00:23Z","updated_at":"2018-10-09T06:44:28Z","pushed_at":"2018-10-09T08:25:43Z","git_url":"git://github.com/apache/arrow.git","ssh_url":"git@github.com:apache/arrow.git","clone_url":"https://github.com/apache/arrow.git","svn_url":"https://github.com/apache/arrow","homepage":"https://arrow.apache.org","size":19029,"stargazers_count":2535,"watchers_count":2535,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":677,"mirror_url":null,"archived":false,"open_issues_count":64,"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":677,"open_issues":64,"watchers":2535,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/arrow/pulls/2727"},"html":{"href":"https://github.com/apache/arrow/pull/2727"},"issue":{"href":"https://api.github.com/repos/apache/arrow/issues/2727"},"comments":{"href":"https://api.github.com/repos/apache/arrow/issues/2727/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/arrow/pulls/2727/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/arrow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/arrow/pulls/2727/commits"},"statuses":{"href":"https://api.github.com/repos/apache/arrow/statuses/ec1a8c2fe924f347f3fe492afb98a92414d5c34d"}},"author_association":"NONE"}}
{"actor":{"display_login":"wesm"}}