[Java] DictionaryEncoder doesn't crash when decoding index outside of Dictionary
まだ誰も着手していません。
評価
調査の方向性
DictionaryEncoder.decode から始め、提供されている testReferencingIndexOutOfBounds テストで動作を再現します。エンコードされたインデックスが辞書の値の数と等しい場合に、期待されるメッセージを伴う IllegalArgumentException が発生することを確認し、有効なインデックスは引き続き正常にデコードされることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug, including details regarding any error messages, version, and platform.
Background
When manually creating an encoded vector, with values referencing indices in a Dictionary, it is possible to have values equal to valueCount of the Dictionary vector i.e. one index out of bounds. This is interpreted as a null value in the Dictionary.
Example
Dictionary
| Index | Original Value |
|---|---|
| 0 | Foo |
Encoded Vector - 1
| Index | Encoded Value | Expected Decode Outcome | Actual Outcome |
|---|---|---|---|
| 0 | 0 | Return the original value | Returns the original value |
Encoded Vector - 2
| Index | Encoded Value | Expected Decode Outcome | Actual Outcome |
|---|---|---|---|
| 0 | 1 | Raise IllegalArgumentException |
Returns null |
Encoded Vector - 3
| Index | Encoded Value | Expected Decode Outcome | Actual Outcome |
|---|---|---|---|
| 0 | 2 | Raise IllegalArgumentException |
Raises IllegalArgumentException |
Test to reproduce the error
@Test
public void testReferencingIndexOutOfBounds() {
// Index at which the original value will be stored at in the dictionary
var encodedIndex = 0;
// The encoded value that references an index in the dictionary
var indexReferenced = 1;
try (final IntVector encodedVector = new IntVector("encodings", allocator);
final VarCharVector dictionaryVector = newVarCharVector("dict", allocator); ) {
var originalValue = "Foo";
dictionaryVector.allocateNew(1);
dictionaryVector.setValueCount(1);
dictionaryVector.set(encodedIndex, originalValue.getBytes(StandardCharsets.UTF_8));
encodedVector.allocateNew(1);
encodedVector.setValueCount(1);
encodedVector.set(0, indexReferenced);
Dictionary dictionary =
new Dictionary(dictionaryVector, new DictionaryEncoding(1L, false, null));
try (ValueVector decoded = DictionaryEncoder.decode(encodedVector, dictionary)) {
fail("There should be an exception when decoding index outside dictionary's range.");
} catch (Exception e) {
assertEquals("Provided dictionary does not contain value for index " + indexReferenced, e.getMessage());
}
}
}
- 主要言語
- Java
- スター
- 95
- フォーク
- 154
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 11
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/arrow-java のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
apache/arrow-java#1261 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/arrow-java#1236 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/arrow-java#1230 ·
-
Type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
apache/arrow-java#1205 ·
-
Type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/arrow-java#1196 · コメント 1 件 ·
apache/arrow-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
checkstyle/test-configs#263 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
1.0.0-alpha2 Type/Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
wso2/dpdp-accelerator#272 ·