Avoid per-write virtual dispatch in `DictionaryValuesWriter.shouldFallBack()` by caching the size-exceeded check
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- java
- Domain
- data-engineering
Research direction
Start with DictionaryValuesWriter.shouldFallBack() and FallbackValuesWriter.checkFallback(), then inspect the Binary, Long, Double, Integer, and Float typed subclass write methods, especially their id == -1 branches. Confirm that the size-exceeded state is updated only when a new dictionary entry is added and that fallback behavior remains unchanged for duplicate writes.
Written by the indexing model from the issue text.
Description
Describe the enhancement requested
DictionaryValuesWriter.shouldFallBack() is called by FallbackValuesWriter.checkFallback() after every single value write. The current implementation dispatches a virtual call to getDictionarySize() on every invocation:
public boolean shouldFallBack() {
return dictionaryByteSize > maxDictionaryByteSize || getDictionarySize() > MAX_DICTIONARY_ENTRIES;
}
getDictionarySize() is an abstract method overridden in each typed subclass (Binary, Long, Double, Integer, Float) to return the backing map's .size(). Since shouldFallBack() is polled after every write, including writes of duplicate values that do not grow the dictionary, the virtual dispatch and map-size query are redundant work for the common case where most values are already in the dictionary.
Both dictionaryByteSize and the dictionary entry count can only increase when a new entry is added (inside the if (id == -1) branch of each subclass's write method). Therefore the size-exceeded condition can only transition from false to true at that exact point.
Proposal
Replace the per-write check with a cached boolean dictionarySizeExceeded flag. Introduce a checkDictionarySizeLimit(int newDictionarySize) method that subclass write methods call only when a new dictionary entry is actually added. shouldFallBack() then returns the cached flag directly, a simple field read with no virtual dispatch.
Component(s)
Core
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.6k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 28
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/parquet-java
-
Type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/parquet-java#3792 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/parquet-java#3767 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/parquet-java#3695 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/parquet-java#3667 ·
-
Type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/parquet-java#3587 ·
All issues in apache/parquet-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FasterXML/jackson-databind#6229 ·