[Java] DictionaryEncoder doesn't crash when decoding index outside of Dictionary
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
Hướng nghiên cứu
Bắt đầu từ DictionaryEncoder.decode và tái hiện hành vi bằng test testReferencingIndexOutOfBounds được cung cấp. Xác nhận rằng một chỉ mục đã mã hóa bằng với số lượng giá trị trong dictionary sẽ phát sinh IllegalArgumentException với thông báo mong đợi, trong khi các chỉ mục hợp lệ vẫn được giải mã bình thường.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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());
}
}
}
- Ngôn ngữ chính
- Java
- Star
- 95
- Fork
- 154
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 9
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/arrow-java
-
Type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/arrow-java#1300 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
apache/arrow-java#1261 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/arrow-java#1236 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/arrow-java#1230 ·
-
Type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
apache/arrow-java#1205 ·
Tất cả issue của apache/arrow-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
infinispan/infinispan#18150 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
opensearch-project/k-NN#3597 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100