[Java] DictionaryEncoder doesn't crash when decoding index outside of Dictionary
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 74/100
Piste de recherche
Commencez par DictionaryEncoder.decode et reproduisez le comportement avec le test testReferencingIndexOutOfBounds fourni. Vérifiez qu’un index encodé égal au nombre de valeurs du dictionnaire lève IllegalArgumentException avec le message attendu, tandis que les index valides sont toujours décodés normalement.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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());
}
}
}
- Langage dominant
- Java
- Étoiles
- 95
- Forks
- 154
- Merge moyen
- 2 j 16 h
- PR mergées (30 j)
- 9
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/arrow-java
-
Type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/arrow-java#1300 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
apache/arrow-java#1261 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/arrow-java#1236 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/arrow-java#1230 ·
-
Type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
apache/arrow-java#1205 ·
Toutes les issues de apache/arrow-java
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
infinispan/infinispan#18150 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
-
untriaged
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100