romainfrancois commented on a change in pull request #11369:
URL: https://github.com/apache/arrow/pull/11369#discussion_r752046159



##########
File path: r/src/altrep.cpp
##########
@@ -215,9 +219,10 @@ struct AltrepVectorPrimitive : public 
AltrepVectorBase<AltrepVectorPrimitive<sex
 
   // The value at position i
   static c_type Elt(SEXP alt, R_xlen_t i) {
-    const auto& array = GetArray(alt);
-    return array->IsNull(i) ? cpp11::na<c_type>()
-                            : array->data()->template GetValues<c_type>(1)[i];
+    auto array = GetChunkedArray(alt)->Slice(i, 1)->chunk(0);

Review comment:
       Thanks. I added this helper struct: 
   
   ```cpp
   struct ArrayResolve {
     ArrayResolve(const std::shared_ptr<ChunkedArray>& chunked_array, int64_t 
i) {
       for (int idx_chunk = 0; idx_chunk < chunked_array->num_chunks(); 
idx_chunk++) {
         std::shared_ptr<Array> chunk = chunked_array->chunk(idx_chunk);
         auto chunk_size = chunk->length();
         if (i < chunk_size) {
           index_ = i;
           array_ = chunk;
           break;
         }
   
         i -= chunk_size;
       }
     }
   
     std::shared_ptr<Array> array_;
     int64_t index_;
   };
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to