Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard ChunkResolver use in altrep.cpp #1

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions cpp/src/arrow/chunk_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,12 @@ class ARROW_EXPORT ChunkResolver {
mutable std::atomic<int32_t> cached_chunk_;

public:
/// \brief Initialize from an `ArrayVector`.
explicit ChunkResolver(const ArrayVector& chunks) noexcept;

/// \brief Initialize from a vector of raw `Array` pointers.
explicit ChunkResolver(const std::vector<const Array*>& chunks) noexcept;

/// \brief Initialize from a `RecordBatchVector`.
///
/// Because all `Array`s in a `RecordBatch` must have the same length, this
/// can be useful for iterating over multiple columns simultaneously.
explicit ChunkResolver(const RecordBatchVector& batches) noexcept;

/// \brief Construct a ChunkResolver from a vector of chunks.size() + 1 offsets.
///
/// The first offset must be 0 and the last offset must be the logical length of the
/// chunked array. Each offset before the last represents the starting logical index of
/// the corresponding chunk.
explicit ChunkResolver(std::vector<int64_t> offsets) noexcept
: offsets_(std::move(offsets)), cached_chunk_(0) {
#ifndef NDEBUG
Expand Down
12 changes: 10 additions & 2 deletions r/src/altrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,26 @@ void DeletePointer(std::shared_ptr<T>* ptr) {
template <typename T>
using Pointer = cpp11::external_pointer<std::shared_ptr<T>, DeletePointer<T>>;

#if ARROW_MAJOR_VERSION >= 18
using ChunkResolver = arrow::ChunkResolver;
using ChunkLocation = arrow::ChunkLocation;
#else
using ChunkResolver = arrow::internal::ChunkResolver;
using ChunkLocation = arrow::internal::ChunkLocation;
#endif

class ArrowAltrepData {
public:
explicit ArrowAltrepData(const std::shared_ptr<ChunkedArray>& chunked_array)
: chunked_array_(chunked_array), resolver_(chunked_array->chunks()) {}

const std::shared_ptr<ChunkedArray>& chunked_array() { return chunked_array_; }

arrow::ChunkLocation locate(int64_t index) { return resolver_.Resolve(index); }
ChunkLocation locate(int64_t index) { return resolver_.Resolve(index); }

private:
std::shared_ptr<ChunkedArray> chunked_array_;
arrow::ChunkResolver resolver_;
ChunkResolver resolver_;
};

// the ChunkedArray that is being wrapped by the altrep object
Expand Down
Loading