[Java] DictionaryProvider leaks memory while adding dictionaries with duplicate encoding
- Langage dominant
- Java
- Étoiles
- 94
- Forks
- 152
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 11
Description
DictionaryProvider leaks memory while adding dictionaries with duplicate encoding. Is this expected? Should the provider release the memory of the existing dictionary vector if it accepts another one with same encoding id ?
Sample code:
```java
"dictionaryProvider" should " not leak memory while adding dictionaries with duplicate encoding" in {
val allocator: RootAllocator = new RootAllocator()
val vector: ListVector = ListVector.empty("vector", allocator)
val dictionaryVector1: ListVector = ListVector.empty("dict1", allocator)
val dictionaryVector2: ListVector = ListVector.empty("dict2", allocator)
val writer1: UnionListWriter = vector.getWriter
writer1.allocate
writer1.setValueCount(1)
val dictWriter1: UnionListWriter = dictionaryVector1.getWriter
dictWriter1.allocate
dictWriter1.setValueCount(1)
val dictWriter2: UnionListWriter = dictionaryVector2.getWriter
dictWriter2.allocate
dictWriter2.setValueCount(1)
val dictionary1: Dictionary = new Dictionary(dictionaryVector1, new DictionaryEncoding(1L, false, None.orNull))
val dictionary2: Dictionary = new Dictionary(dictionaryVector2, new DictionaryEncoding(1L, false, None.orNull))
val provider = new DictionaryProvider.MapDictionaryProvider
provider.put(dictionary1)
provider.put(dictionary2)
vector.clear()
provider.getDictionaryIds.asScala.map(id => provider.lookup(id).getVector.clear())
allocator.getAllocatedMemory shouldBe 0
}
```
**Reporter**: [Vimal Varghese](https://issues.apache.org/jira/browse/ARROW-16920)
**Note**: *This issue was originally created as [ARROW-16920](https://issues.apache.org/jira/browse/ARROW-16920). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par DictionaryProvider.MapDictionaryProvider et exécutez la reproduction fournie, qui ajoute deux dictionnaires avec l'encoding ID 1, vide le vecteur et vérifie la mémoire de l'allocator. Suivez ce qui arrive au premier dictionnaire lorsque le second est inséré ; le travail est terminé lorsque le cas d'un encoding dupliqué libère toute la mémoire allouée et que la vérification finale des allocations atteint zéro.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- data
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100