[Java] DictionaryProvider leaks memory while adding dictionaries with duplicate encoding
- Vorherrschende Sprache
- Java
- Sterne
- 94
- Forks
- 152
- Ø Merge
- 3 T. 16 Std.
- Gemergte PRs (30 T.)
- 11
Beschreibung
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.*
Beitragsleitfaden
Rechercherichtung
Beginnen Sie bei DictionaryProvider.MapDictionaryProvider und führen Sie die mitgelieferte Reproduktion aus, die zwei Wörterbücher mit der encoding ID 1 hinzufügt, den Vektor leert und den Allocator-Speicher prüft. Verfolgen Sie, was mit dem ersten Wörterbuch passiert, wenn das zweite eingefügt wird; abgeschlossen ist die Aufgabe, wenn der Fall doppelter encoding IDs den gesamten zugewiesenen Speicher freigibt und die abschließende Allokationsprüfung null erreicht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- data
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100