chore(deps): Upgrade jol-core to latest#143
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpgrades the stats module’s jol-core dependency (and related build plugins/parent) and adjusts memory-size estimation APIs and constants from int to long to be compatible with the newer JOL version and larger instance sizes. Class diagram for updated memory size estimation APIsclassDiagram
class HllInstance {
<<interface>>
+int getIndexBitLength()
+long estimatedInMemorySize()
+int estimatedSerializedSize()
}
class DenseHll {
-static final long DENSE_INSTANCE_SIZE
-static final int OVERFLOW_GROW_INCREMENT
-byte indexBitLength
+void insertHash(long hash)
+long cardinality()
+long estimatedInMemorySize()
}
class SparseHll {
<<final>>
-static final long SPARSE_INSTANCE_SIZE
+long cardinality()
+long estimatedInMemorySize()
}
class HyperLogLog {
-static final long INSTANCE_SIZE
-static final int MAX_NUMBER_OF_BUCKETS
-HllInstance instance
+void add(long value)
+void addHash(long hash)
+long cardinality()
+void eachBucket(BucketListener listener)
+long estimatedInMemorySize()
}
class QuantileDigest {
-static final int MAX_BITS
-static final long QUANTILE_DIGEST_SIZE
}
HllInstance <|.. DenseHll
HllInstance <|.. SparseHll
HyperLogLog o-- HllInstance
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Changing
estimatedInMemorySize()frominttolong(e.g., inHllInstanceandHyperLogLog) is a public API break; consider whether a backwards-compatible approach (e.g., adding a newlong-returning method and deprecating the old one) is needed for downstream users. - The parent
airbaseversion was updated to109-SNAPSHOT; for a released branch/module you may want to depend on a non-SNAPSHOT version to avoid build instability and implicit behavior changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Changing `estimatedInMemorySize()` from `int` to `long` (e.g., in `HllInstance` and `HyperLogLog`) is a public API break; consider whether a backwards-compatible approach (e.g., adding a new `long`-returning method and deprecating the old one) is needed for downstream users.
- The parent `airbase` version was updated to `109-SNAPSHOT`; for a released branch/module you may want to depend on a non-SNAPSHOT version to avoid build instability and implicit behavior changes.
## Individual Comments
### Comment 1
<location> `stats/src/main/java/com/facebook/airlift/stats/cardinality/SparseHll.java:195-197` </location>
<code_context>
@Override
- public int estimatedInMemorySize()
+ public long estimatedInMemorySize()
{
- return (int) (DENSE_INSTANCE_SIZE +
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Avoid narrowing to int in estimatedInMemorySize now that it returns long
Since `estimatedInMemorySize()` now returns a `long`, using `toIntExact(sizeOf(entries))` adds an unnecessary narrowing step and can overflow. Consider returning `SPARSE_INSTANCE_SIZE + sizeOf(entries)` directly as a `long` to keep the calculation in `long` space. If you do need to preserve the prior `int`-based behavior, please add a short comment explaining why overflow is acceptable here.
Suggested implementation:
```java
@Override
public long estimatedInMemorySize()
{
return SPARSE_INSTANCE_SIZE + sizeOf(entries);
}
```
If this file (or a common import section for this class) includes a static import for `toIntExact`, such as:
```java
import static java.lang.Math.toIntExact;
```
that import should be removed, since it will no longer be used.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| public long estimatedInMemorySize() | ||
| { | ||
| return SPARSE_INSTANCE_SIZE + toIntExact(sizeOf(entries)); |
There was a problem hiding this comment.
suggestion (bug_risk): Avoid narrowing to int in estimatedInMemorySize now that it returns long
Since estimatedInMemorySize() now returns a long, using toIntExact(sizeOf(entries)) adds an unnecessary narrowing step and can overflow. Consider returning SPARSE_INSTANCE_SIZE + sizeOf(entries) directly as a long to keep the calculation in long space. If you do need to preserve the prior int-based behavior, please add a short comment explaining why overflow is acceptable here.
Suggested implementation:
@Override
public long estimatedInMemorySize()
{
return SPARSE_INSTANCE_SIZE + sizeOf(entries);
}If this file (or a common import section for this class) includes a static import for toIntExact, such as:
import static java.lang.Math.toIntExact;that import should be removed, since it will no longer be used.
fd0b590 to
91675af
Compare
|



Fixes: