apache / apache/arrow

[C++] Add concrete ArraySpan classes

Open
#37,153 10 comments 0 reactions 0 assignees View on GitHub
Component: C++ Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the enhancement requested

`ArraySpan` is a lighter-weight facility that `ArrayData` and `Array`, but it does not expose as many helpers, making it uneasy to use efficiently inside compute kernels.

Perhaps we should add concrete classes providing additional behaviour around `ArraySpan`, for example:
```c++

class ConcreteArraySpan {
protected:
ArraySpan* span;
public:
ConcreteArraySpan(const ArraySpan& span) : span(&span) {}
};

template
class NumericArraySpan : public ConcreteArraySpan {
ArraySpan* span;
public:
using value_type = typename TypeClass::c_type;
using ConcreteArraySpan::ConcreteArraySpan;

bool IsValid(int64_t index) const { ... }
value_type GetView(int64_t index) const { ... }
};

class BinaryArraySpan {
...
bool IsValid(int64_t index) const { ... }
std::string_view GetView(int64_t index) const { ... }
}
```

### Component(s)

C++

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.