felipecrv commented on code in PR #35628:
URL: https://github.com/apache/arrow/pull/35628#discussion_r1231532491
##########
cpp/src/arrow/array/array_binary.h:
##########
@@ -217,6 +218,90 @@ class ARROW_EXPORT LargeStringArray : public
LargeBinaryArray {
Status ValidateUTF8() const;
};
+// ----------------------------------------------------------------------
+// BinaryView and StringView
+
+/// Concrete Array class for variable-size binary view data using the
+/// StringHeader struct to reference in-line or out-of-line string values
+class ARROW_EXPORT BinaryViewArray : public PrimitiveArray {
+ public:
+ using TypeClass = BinaryViewType;
+ using IteratorType = stl::ArrayIterator<BinaryViewArray>;
+
+ explicit BinaryViewArray(const std::shared_ptr<ArrayData>& data);
+
+ BinaryViewArray(int64_t length, std::shared_ptr<Buffer> data, BufferVector
char_buffers,
+ std::shared_ptr<Buffer> null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0)
+ : PrimitiveArray(binary_view(), length, std::move(data),
std::move(null_bitmap),
+ null_count, offset) {
+ for (auto& char_buffer : char_buffers) {
+ data_->buffers.push_back(std::move(char_buffer));
+ }
+ }
+
+ const StringHeader* raw_values() const {
+ return reinterpret_cast<const StringHeader*>(raw_values_) + data_->offset;
+ }
+
+ // For API compatibility with BinaryArray etc.
+ std::string_view GetView(int64_t i) const {
+ const auto& s = raw_values()[i];
+ if (raw_pointers_) {
+ return std::string_view{s};
Review Comment:
Either do that or replace the `auto&` with `StringHeader&`.
--
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]