{"action":"created","comment":{"url":"https://api.github.com/repos/apache/arrow/pulls/comments/219813151","pull_request_review_id":158074571,"id":219813151,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxOTgxMzE1MQ==","diff_hunk":"@@ -0,0 +1,209 @@\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,\n+// software distributed under the License is distributed on an\n+// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+// KIND, either express or implied.  See the License for the\n+// specific language governing permissions and limitations\n+// under the License.\n+\n+#include \"arrow_types.h\"\n+\n+using namespace Rcpp;\n+using namespace arrow;\n+\n+namespace arrow{\n+namespace r{\n+\n+template <int RTYPE, typename Vec = Rcpp::Vector<RTYPE> >\n+class SimpleRBuffer : public arrow::Buffer {\n+public:\n+\n+  SimpleRBuffer(Vec vec) :\n+    Buffer(reinterpret_cast<const uint8_t*>(vec.begin()), vec.size() * sizeof(typename Vec::stored_type)),\n+    vec_(vec)\n+  {}\n+\n+private:\n+  // vec_ holds the memory\n+  Vec vec_;\n+};\n+\n+template <int RTYPE, typename Type>\n+std::shared_ptr<arrow::Array> SimpleArray(SEXP x){\n+\n+  Rcpp::Vector<RTYPE> vec(x);\n+  std::vector<std::shared_ptr<arrow::Buffer>> buffers {\n+    nullptr,\n+    std::make_shared<SimpleRBuffer<RTYPE>>(vec)\n+  };\n+\n+  int null_count = 0;\n+  if (RTYPE != RAWSXP) {\n+    // TODO: maybe first count NA in a first pass so that we\n+    //       can allocate only if needed\n+    std::shared_ptr<arrow::Buffer> null_bitmap;\n+    R_ERROR_NOT_OK(arrow::AllocateBuffer(vec.size(), &null_bitmap));\n+\n+    auto null_bitmap_data = null_bitmap->mutable_data();\n+    for (int i=0; i < vec.size(); i++) {\n+      if (Rcpp::Vector<RTYPE>::is_na(vec[i]) ) {\n+        BitUtil::SetBit(null_bitmap_data, i);\n+        null_count++;\n+      } else {\n+        BitUtil::ClearBit(null_bitmap_data, i);\n+      }\n+    }\n+    buffers[0] = std::move(null_bitmap);\n+  }\n+\n+  auto data = ArrayData::Make(\n+    std::make_shared<Type>(),\n+    LENGTH(x),\n+    std::move(buffers),\n+    null_count,\n+    0 /*offset*/\n+  );\n+\n+  // return the right Array class\n+  return std::make_shared<arrow::NumericArray<Type>>(data);\n+}\n+\n+}\n+}\n+\n+// [[Rcpp::export]]\n+std::shared_ptr<arrow::Array> Array__from_vector(SEXP x){\n+  switch(TYPEOF(x)){\n+    case INTSXP:\n+      if (Rf_isFactor(x)) {\n+        break;\n+      }\n+    return arrow::r::SimpleArray<INTSXP, arrow::Int32Type>(x);\n+    case REALSXP:\n+      // TODO: Dates, ...\n+    return arrow::r::SimpleArray<REALSXP, arrow::DoubleType>(x);\n+    case RAWSXP:\n+      return arrow::r::SimpleArray<RAWSXP, arrow::Int8Type>(x);\n+    default:\n+      break;\n+  }\n+\n+  stop(\"not handled\");\n+  return nullptr;\n+}\n+\n+\n+template <int RTYPE>\n+inline SEXP simple_Array_to_Vector(const std::shared_ptr<arrow::Array>& array ){\n+  using stored_type = typename Rcpp::Vector<RTYPE>::stored_type;\n+  auto start = reinterpret_cast<const stored_type*>(array->data()->buffers[1]->data() + array->offset() * sizeof(stored_type));\n+\n+  size_t n = array->length();\n+  Rcpp::Vector<RTYPE> vec(start, start + n);\n+  if (array->null_count() && RTYPE != RAWSXP) {\n+    // TODO: not sure what to do with RAWSXP since\n+    //       R raw vector do not have a concept of missing data\n+\n+    auto bitmap_data = array->null_bitmap()->data();\n+    for (size_t i=0; i < n; i++) {\n+      if (BitUtil::GetBit(bitmap_data, i)) {","path":"r/src/array.cpp","position":118,"original_position":118,"commit_id":"a80daaca8e0df1c31cd435ece73f7de6323173cf","original_commit_id":"a80daaca8e0df1c31cd435ece73f7de6323173cf","user":{"login":"romainfrancois","id":2625526,"node_id":"MDQ6VXNlcjI2MjU1MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/2625526?v=4","gravatar_id":"","url":"https://api.github.com/users/romainfrancois","html_url":"https://github.com/romainfrancois","followers_url":"https://api.github.com/users/romainfrancois/followers","following_url":"https://api.github.com/users/romainfrancois/following{/other_user}","gists_url":"https://api.github.com/users/romainfrancois/gists{/gist_id}","starred_url":"https://api.github.com/users/romainfrancois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romainfrancois/subscriptions","organizations_url":"https://api.github.com/users/romainfrancois/orgs","repos_url":"https://api.github.com/users/romainfrancois/repos","events_url":"https://api.github.com/users/romainfrancois/events{/privacy}","received_events_url":"https://api.github.com/users/romainfrancois/received_events","type":"User","site_admin":false},"body":"Thanks. ","created_at":"2018-09-24T12:13:27Z","updated_at":"2018-09-24T12:13:27Z","html_url":"https://github.com/apache/arrow/pull/2596#discussion_r219813151","pull_request_url":"https://api.github.com/repos/apache/arrow/pulls/2596","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/arrow/pulls/comments/219813151"},"html":{"href":"https://github.com/apache/arrow/pull/2596#discussion_r219813151"},"pull_request":{"href":"https://api.github.com/repos/apache/arrow/pulls/2596"}},"in_reply_to_id":219793604},"pull_request":{"url":"https://api.github.com/repos/apache/arrow/pulls/2596","id":217305558,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3MzA1NTU4","html_url":"https://github.com/apache/arrow/pull/2596","diff_url":"https://github.com/apache/arrow/pull/2596.diff","patch_url":"https://github.com/apache/arrow/pull/2596.patch","issue_url":"https://api.github.com/repos/apache/arrow/issues/2596","number":2596,"state":"open","locked":false,"title":"ARROW-3282: [R] initial R functionality","user":{"login":"romainfrancois","id":2625526,"node_id":"MDQ6VXNlcjI2MjU1MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/2625526?v=4","gravatar_id":"","url":"https://api.github.com/users/romainfrancois","html_url":"https://github.com/romainfrancois","followers_url":"https://api.github.com/users/romainfrancois/followers","following_url":"https://api.github.com/users/romainfrancois/following{/other_user}","gists_url":"https://api.github.com/users/romainfrancois/gists{/gist_id}","starred_url":"https://api.github.com/users/romainfrancois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romainfrancois/subscriptions","organizations_url":"https://api.github.com/users/romainfrancois/orgs","repos_url":"https://api.github.com/users/romainfrancois/repos","events_url":"https://api.github.com/users/romainfrancois/events{/privacy}","received_events_url":"https://api.github.com/users/romainfrancois/received_events","type":"User","site_admin":false},"body":"* Wrapping C++ pointers to arrow objects as R6 classes holding an R external pointer. \r\n* Factory functions for the metadata types, int32(), ...\r\n* Factory to create schemas and struct\r\n* Create Array, RecordBatch, Table from R vectors and data frames. initially only support integer (int32), numeric (float64) and raw (int8) vectors. \r\n* Reading and Writing record batches and Table to files. ","created_at":"2018-09-21T14:38:54Z","updated_at":"2018-09-24T12:13:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"362eeef6b61c8dbb5e878c99259bfbc75d690194","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/arrow/pulls/2596/commits","review_comments_url":"https://api.github.com/repos/apache/arrow/pulls/2596/comments","review_comment_url":"https://api.github.com/repos/apache/arrow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/arrow/issues/2596/comments","statuses_url":"https://api.github.com/repos/apache/arrow/statuses/a80daaca8e0df1c31cd435ece73f7de6323173cf","head":{"label":"romainfrancois:r-dev-buffer","ref":"r-dev-buffer","sha":"a80daaca8e0df1c31cd435ece73f7de6323173cf","user":{"login":"romainfrancois","id":2625526,"node_id":"MDQ6VXNlcjI2MjU1MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/2625526?v=4","gravatar_id":"","url":"https://api.github.com/users/romainfrancois","html_url":"https://github.com/romainfrancois","followers_url":"https://api.github.com/users/romainfrancois/followers","following_url":"https://api.github.com/users/romainfrancois/following{/other_user}","gists_url":"https://api.github.com/users/romainfrancois/gists{/gist_id}","starred_url":"https://api.github.com/users/romainfrancois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romainfrancois/subscriptions","organizations_url":"https://api.github.com/users/romainfrancois/orgs","repos_url":"https://api.github.com/users/romainfrancois/repos","events_url":"https://api.github.com/users/romainfrancois/events{/privacy}","received_events_url":"https://api.github.com/users/romainfrancois/received_events","type":"User","site_admin":false},"repo":{"id":124081421,"node_id":"MDEwOlJlcG9zaXRvcnkxMjQwODE0MjE=","name":"arrow","full_name":"romainfrancois/arrow","private":false,"owner":{"login":"romainfrancois","id":2625526,"node_id":"MDQ6VXNlcjI2MjU1MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/2625526?v=4","gravatar_id":"","url":"https://api.github.com/users/romainfrancois","html_url":"https://github.com/romainfrancois","followers_url":"https://api.github.com/users/romainfrancois/followers","following_url":"https://api.github.com/users/romainfrancois/following{/other_user}","gists_url":"https://api.github.com/users/romainfrancois/gists{/gist_id}","starred_url":"https://api.github.com/users/romainfrancois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romainfrancois/subscriptions","organizations_url":"https://api.github.com/users/romainfrancois/orgs","repos_url":"https://api.github.com/users/romainfrancois/repos","events_url":"https://api.github.com/users/romainfrancois/events{/privacy}","received_events_url":"https://api.github.com/users/romainfrancois/received_events","type":"User","site_admin":false},"html_url":"https://github.com/romainfrancois/arrow","description":"******* In this fork I only work on the r/ directory, please refer to the upstream repo for all of Arrow******","fork":true,"url":"https://api.github.com/repos/romainfrancois/arrow","forks_url":"https://api.github.com/repos/romainfrancois/arrow/forks","keys_url":"https://api.github.com/repos/romainfrancois/arrow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romainfrancois/arrow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romainfrancois/arrow/teams","hooks_url":"https://api.github.com/repos/romainfrancois/arrow/hooks","issue_events_url":"https://api.github.com/repos/romainfrancois/arrow/issues/events{/number}","events_url":"https://api.github.com/repos/romainfrancois/arrow/events","assignees_url":"https://api.github.com/repos/romainfrancois/arrow/assignees{/user}","branches_url":"https://api.github.com/repos/romainfrancois/arrow/branches{/branch}","tags_url":"https://api.github.com/repos/romainfrancois/arrow/tags","blobs_url":"https://api.github.com/repos/romainfrancois/arrow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romainfrancois/arrow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romainfrancois/arrow/git/refs{/sha}","trees_url":"https://api.github.com/repos/romainfrancois/arrow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romainfrancois/arrow/statuses/{sha}","languages_url":"https://api.github.com/repos/romainfrancois/arrow/languages","stargazers_url":"https://api.github.com/repos/romainfrancois/arrow/stargazers","contributors_url":"https://api.github.com/repos/romainfrancois/arrow/contributors","subscribers_url":"https://api.github.com/repos/romainfrancois/arrow/subscribers","subscription_url":"https://api.github.com/repos/romainfrancois/arrow/subscription","commits_url":"https://api.github.com/repos/romainfrancois/arrow/commits{/sha}","git_commits_url":"https://api.github.com/repos/romainfrancois/arrow/git/commits{/sha}","comments_url":"https://api.github.com/repos/romainfrancois/arrow/comments{/number}","issue_comment_url":"https://api.github.com/repos/romainfrancois/arrow/issues/comments{/number}","contents_url":"https://api.github.com/repos/romainfrancois/arrow/contents/{+path}","compare_url":"https://api.github.com/repos/romainfrancois/arrow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romainfrancois/arrow/merges","archive_url":"https://api.github.com/repos/romainfrancois/arrow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romainfrancois/arrow/downloads","issues_url":"https://api.github.com/repos/romainfrancois/arrow/issues{/number}","pulls_url":"https://api.github.com/repos/romainfrancois/arrow/pulls{/number}","milestones_url":"https://api.github.com/repos/romainfrancois/arrow/milestones{/number}","notifications_url":"https://api.github.com/repos/romainfrancois/arrow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romainfrancois/arrow/labels{/name}","releases_url":"https://api.github.com/repos/romainfrancois/arrow/releases{/id}","deployments_url":"https://api.github.com/repos/romainfrancois/arrow/deployments","created_at":"2018-03-06T13:21:28Z","updated_at":"2018-09-22T10:30:44Z","pushed_at":"2018-09-22T10:30:42Z","git_url":"git://github.com/romainfrancois/arrow.git","ssh_url":"git@github.com:romainfrancois/arrow.git","clone_url":"https://github.com/romainfrancois/arrow.git","svn_url":"https://github.com/romainfrancois/arrow","homepage":"https://arrow.apache.org","size":17537,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"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":2,"open_issues":1,"watchers":12,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"e2c4b09dc0c1369117ab7e7c20bf93bbfcc76b5d","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-09-24T10:22:11Z","pushed_at":"2018-09-24T11:44:47Z","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":17569,"stargazers_count":2483,"watchers_count":2483,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":655,"mirror_url":null,"archived":false,"open_issues_count":56,"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":655,"open_issues":56,"watchers":2483,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/arrow/pulls/2596"},"html":{"href":"https://github.com/apache/arrow/pull/2596"},"issue":{"href":"https://api.github.com/repos/apache/arrow/issues/2596"},"comments":{"href":"https://api.github.com/repos/apache/arrow/issues/2596/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/arrow/pulls/2596/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/arrow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/arrow/pulls/2596/commits"},"statuses":{"href":"https://api.github.com/repos/apache/arrow/statuses/a80daaca8e0df1c31cd435ece73f7de6323173cf"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"romainfrancois"}}