[Ruby] Wrong data pointer in MemoryView of a sliced array
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
ext/arrow/memory-view.cpp 内の PrimitiveArrayGetter::fill から着手する。ここでは GetValuesSafe<uint8_t>(1) が配列のオフセットを要素単位ではなくバイト単位で適用している。issue 内のスニペット(スライスした Arrow::Int32Array を Fiddle::MemoryView 経由で読み戻すもの)で再現し、その後、オフセットを固定幅要素サイズでスケールする(issue に提案されたスニペットの通り)ことで、data、item_size、byte_size が整合するようにする。マルチバイトのプリミティブ配列のスライスが期待どおりの値をアンパックするようになったら完了。ext/arrow のテストスイートに拡張可能な既存の memory-view テストがあるか確認する。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug, including details regarding any error messages, version, and platform.
For a sliced primitive array, the data pointer of the exported
MemoryView is advanced by offset bytes instead of
offset × element size bytes, so values wider than one byte come
out wrong (no error is raised).
require "arrow"
require "fiddle"
a = Arrow::Int32Array.new([0, 1, 2, 3, 4, 5, 6, 7])
p Fiddle::MemoryView.new(a.slice(1, 3)).to_s.unpack("l*")
# => [16777216, 33554432, 50331648] expected [1, 2, 3]
p Fiddle::MemoryView.new(a.slice(4, 3)).to_s.unpack("l*")
# => [1, 2, 3] expected [4, 5, 6]
The cause is GetValuesSafe<uint8_t>(1) in PrimitiveArrayGetter::fill
(ext/arrow/memory-view.cpp): it adds the offset in units of uint8_t.
The offset should be scaled by the element width.
A possible fix is to take the buffer start and scale the offset by the
element width:
const auto type =
std::static_pointer_cast<const arrow::FixedWidthType>(array.type());
view_->item_size = type->bit_width() / 8;
const auto base = array_data->GetValuesSafe<uint8_t>(1, 0);
const auto data = base + array_data->offset * view_->item_size;
view_->data = const_cast<void *>(reinterpret_cast<const void *>(data));
view_->byte_size = view_->item_size * array.length();
red-arrow 25.0.1, Ruby 3.4.1, macOS (arm64).
Component(s)
Ruby
- 主要言語
- C++
- スター
- 17.2k
- フォーク
- 4.3k
- 平均マージ
- 4日 5時間
- マージ済み PR(30日)
- 101
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/arrow のほかの issue
-
[C++] GetSchema labels its null check on each schema field as "DictionaryEncoding.indexType"対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンComponent: C++
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
[C++][Python] IPC reader rejects a DictionaryEncoding without indexType, which the format allows対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンComponent: C++ Component: Python
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Component: R Type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/arrow#51695 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[C++][Parquet] Plaintext-footer files written with AES_GCM_CTR_V1 record AES_GCM_V1 as the encryption algorithm and cannot be read対応中かも @YusefSyed が 4 日前に担当しました。 オープンType: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
[R] Expose ignore_extra_columns and pad_short_rows CSV parse options対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンComponent: R good-first-issue Type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
libasr headers?オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
bug iOS 🍎 ui/ux
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MerginMaps/mobile#4744 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
kokkos/kokkos-kernels#3328 ·
メンテナーはふだん 1 日以内に返信
-
bug needs triage tcp
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
project-chip/connectedhomeip#74644 ·
メンテナーはふだん 1 日以内に返信