[ 
https://issues.apache.org/jira/browse/ARROW-1886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16407174#comment-16407174
 ] 

ASF GitHub Bot commented on ARROW-1886:
---------------------------------------

cpcloud commented on a change in pull request #1768: ARROW-1886: [C++/Python] 
Flatten struct columns in table 
URL: https://github.com/apache/arrow/pull/1768#discussion_r175944515
 
 

 ##########
 File path: cpp/src/arrow/util/bit-util.cc
 ##########
 @@ -172,4 +172,58 @@ bool BitmapEquals(const uint8_t* left, int64_t 
left_offset, const uint8_t* right
   return true;
 }
 
+namespace {
+
+void AlignedBitmapAnd(const uint8_t* left, int64_t left_offset, const uint8_t* 
right,
+                      int64_t right_offset, uint8_t* out, int64_t out_offset,
+                      int64_t length) {
+  DCHECK_EQ(left_offset % 8, right_offset % 8);
+  DCHECK_EQ(left_offset % 8, out_offset % 8);
+
+  const int64_t nbytes = BitUtil::BytesForBits(length + left_offset);
+  left += left_offset / 8;
+  right += right_offset / 8;
+  out += out_offset / 8;
+  for (int64_t i = 0; i < nbytes; ++i) {
+    out[i] = left[i] & right[i];
+  }
+}
+
+void UnalignedBitmapAnd(const uint8_t* left, int64_t left_offset, const 
uint8_t* right,
+                        int64_t right_offset, uint8_t* out, int64_t out_offset,
+                        int64_t length) {
+  auto left_reader = internal::BitmapReader(left, left_offset, length);
+  auto right_reader = internal::BitmapReader(right, right_offset, length);
+  auto writer = internal::BitmapWriter(out, out_offset, length);
+  for (int64_t i = 0; i < length; ++i) {
+    if (left_reader.IsSet() && right_reader.IsSet()) {
+      writer.Set();
+    }
+    left_reader.Next();
+    right_reader.Next();
+    writer.Next();
+  }
+  writer.Finish();
+}
+
+}  // namespace
+
+Status BitmapAnd(MemoryPool* pool, const uint8_t* left, int64_t left_offset,
+                 const uint8_t* right, int64_t right_offset, int64_t length,
+                 int64_t out_offset, std::shared_ptr<Buffer>* out_buffer) {
 
 Review comment:
   I guess there's some precedent here for that, but calling this `BitmapAnd` 
and having it take `MemoryPool` as its first argument is confusing.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Add function to "flatten" structs within tables
> --------------------------------------------------------
>
>                 Key: ARROW-1886
>                 URL: https://issues.apache.org/jira/browse/ARROW-1886
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Wes McKinney
>            Assignee: Antoine Pitrou
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.10.0
>
>
> See discussion in https://issues.apache.org/jira/browse/ARROW-1873
> When a user has a struct column, it may be more efficient to flatten the 
> struct into multiple columns of the form {{struct_name.field_name}} for each 
> field in the struct. Then when you call {{to_pandas}}, Python dictionaries do 
> not have to be created, and the conversion will be much more efficient



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to