[
https://issues.apache.org/jira/browse/ARROW-1904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16286053#comment-16286053
]
ASF GitHub Bot commented on ARROW-1904:
---------------------------------------
wesm closed pull request #1409: ARROW-1904: [C++] Deprecate
PrimitiveArray::raw_values
URL: https://github.com/apache/arrow/pull/1409
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc
index 0b235cc19..144fbcd05 100644
--- a/cpp/src/arrow/array.cc
+++ b/cpp/src/arrow/array.cc
@@ -139,11 +139,15 @@ PrimitiveArray::PrimitiveArray(const
std::shared_ptr<DataType>& type, int64_t le
SetData(ArrayData::Make(type, length, {null_bitmap, data}, null_count,
offset));
}
+#ifndef ARROW_NO_DEPRECATED_API
+
const uint8_t* PrimitiveArray::raw_values() const {
return raw_values_ +
offset() * static_cast<const FixedWidthType&>(*type()).bit_width() /
CHAR_BIT;
}
+#endif
+
template <typename T>
NumericArray<T>::NumericArray(const std::shared_ptr<ArrayData>& data)
: PrimitiveArray(data) {
diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h
index ebe54adcb..6721c7d27 100644
--- a/cpp/src/arrow/array.h
+++ b/cpp/src/arrow/array.h
@@ -334,9 +334,15 @@ class ARROW_EXPORT PrimitiveArray : public FlatArray {
/// Does not account for any slice offset
std::shared_ptr<Buffer> values() const { return data_->buffers[1]; }
+#ifndef ARROW_NO_DEPRECATED_API
+
/// \brief Return pointer to start of raw data
+ ///
+ /// \note Deprecated since 0.8.0
const uint8_t* raw_values() const;
+#endif
+
protected:
PrimitiveArray() {}
@@ -567,6 +573,8 @@ class ARROW_EXPORT FixedSizeBinaryArray : public
PrimitiveArray {
int32_t byte_width() const { return byte_width_; }
+ const uint8_t* raw_values() const { return raw_values_ + data_->offset *
byte_width_; }
+
protected:
inline void SetData(const std::shared_ptr<ArrayData>& data) {
this->PrimitiveArray::SetData(data);
diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc
index 72ef122e3..9f07fa7ef 100644
--- a/cpp/src/arrow/compare.cc
+++ b/cpp/src/arrow/compare.cc
@@ -312,8 +312,16 @@ static bool IsEqualPrimitive(const PrimitiveArray& left,
const PrimitiveArray& r
const auto& size_meta = dynamic_cast<const FixedWidthType&>(*left.type());
const int byte_width = size_meta.bit_width() / CHAR_BIT;
- const uint8_t* left_data = left.values() ? left.raw_values() : nullptr;
- const uint8_t* right_data = right.values() ? right.raw_values() : nullptr;
+ const uint8_t* left_data = nullptr;
+ const uint8_t* right_data = nullptr;
+
+ if (left.values()) {
+ left_data = left.values()->data() + left.offset() * byte_width;
+ }
+
+ if (right.values()) {
+ right_data = right.values()->data() + right.offset() * byte_width;
+ }
if (left.null_count() > 0) {
for (int64_t i = 0; i < left.length(); ++i) {
----------------------------------------------------------------
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:
[email protected]
> [C++] Deprecate PrimitiveArray::raw_values
> ------------------------------------------
>
> Key: ARROW-1904
> URL: https://issues.apache.org/jira/browse/ARROW-1904
> Project: Apache Arrow
> Issue Type: Bug
> Components: C++
> Reporter: Wes McKinney
> Assignee: Wes McKinney
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> I ran into an odd issue where, even though I was casting to
> {{arrow::PrimitiveArray}}, it picked up the {{raw_values}} method from a
> subclass of {{PrimitiveArray}} (which includes a slice offset)
> {code}
> (gdb) p reinterpret_cast<const int64_t*>(reinterpret_cast<const
> PrimitiveArray&>(arr).raw_values())[0]
> $9 = 25
> (gdb) p reinterpret_cast<const int64_t*>(reinterpret_cast<const
> PrimitiveArray&>(arr).raw_values_)[0]
> $10 = 10
> (gdb) p arr.offset()
> $11 = 15
> {code}
> I think the {{raw_values}} method in PrimitiveArray should be deprecated and
> removed, since it is dangerous to use as it does not include a slice offset,
> if any
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)