Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.5.1</version>
<version>3.11.0</version>
<executions>
<execution>
<id>help-mojo</id>
Expand All @@ -357,7 +357,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.6.0</version>
</plugin>

<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void testConnectTimeout()
super.testConnectTimeout();
}

@Test(expectedExceptions = {IOException.class})
@Test(expectedExceptions = IOException.class)
public void testCertHostnameMismatch()
throws Exception
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>com.facebook.airlift</groupId>
<artifactId>airbase</artifactId>
<version>108</version>
<version>109</version>
</parent>

<inceptionYear>2010</inceptionYear>
Expand Down
3 changes: 2 additions & 1 deletion stats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@
<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
<version>0.45</version>
</dependency>

<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<version>0.2</version>
<version>0.17</version>
</dependency>

<!-- for testing -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
public class QuantileDigest
{
private static final int MAX_BITS = 64;
private static final int QUANTILE_DIGEST_SIZE = ClassLayout.parseClass(QuantileDigest.class).instanceSize();
private static final long QUANTILE_DIGEST_SIZE = ClassLayout.parseClass(QuantileDigest.class).instanceSize();

// needs to be such that Math.exp(alpha * seconds) does not grow too big
static final long RESCALE_THRESHOLD_SECONDS = 50;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class DenseHll
private static final int MAX_DELTA = (1 << BITS_PER_BUCKET) - 1;
private static final int BUCKET_MASK = (1 << BITS_PER_BUCKET) - 1;

private static final int DENSE_INSTANCE_SIZE = ClassLayout.parseClass(DenseHll.class).instanceSize();
private static final long DENSE_INSTANCE_SIZE = ClassLayout.parseClass(DenseHll.class).instanceSize();
private static final int OVERFLOW_GROW_INCREMENT = 5;

private final byte indexBitLength;
Expand Down Expand Up @@ -148,9 +148,9 @@ public void insertHash(long hash)
}

@Override
public int estimatedInMemorySize()
public long estimatedInMemorySize()
{
return (int) (DENSE_INSTANCE_SIZE +
return (DENSE_INSTANCE_SIZE +
SizeOf.sizeOf(deltas) +
SizeOf.sizeOf(overflowBuckets) +
SizeOf.sizeOf(overflowValues));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface HllInstance

int getIndexBitLength();

int estimatedInMemorySize();
long estimatedInMemorySize();

int estimatedSerializedSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

public class HyperLogLog
{
private static final int INSTANCE_SIZE = ClassLayout.parseClass(HyperLogLog.class).instanceSize();
private static final long INSTANCE_SIZE = ClassLayout.parseClass(HyperLogLog.class).instanceSize();
private static final int MAX_NUMBER_OF_BUCKETS = 65536;
private HllInstance instance;

Expand Down Expand Up @@ -106,7 +106,7 @@ public void eachBucket(BucketListener listener)
instance.eachBucket(listener);
}

public int estimatedInMemorySize()
public long estimatedInMemorySize()
{
return instance.estimatedInMemorySize() + INSTANCE_SIZE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
final class SparseHll
implements HllInstance
{
private static final int SPARSE_INSTANCE_SIZE = ClassLayout.parseClass(SparseHll.class).instanceSize();
private static final long SPARSE_INSTANCE_SIZE = ClassLayout.parseClass(SparseHll.class).instanceSize();

// 6 bits to encode the number of zeros after the truncated hash
// and be able to fit the encoded value in an integer
Expand Down Expand Up @@ -192,7 +192,7 @@ public long cardinality()
}

@Override
public int estimatedInMemorySize()
public long estimatedInMemorySize()
{
return SPARSE_INSTANCE_SIZE + toIntExact(sizeOf(entries));
Comment on lines +195 to 197
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class TestSparseHll
{
private static final int SPARSE_HLL_INSTANCE_SIZE = ClassLayout.parseClass(SparseHll.class).instanceSize();
private static final long SPARSE_HLL_INSTANCE_SIZE = ClassLayout.parseClass(SparseHll.class).instanceSize();

@Test(dataProvider = "bits")
public void testNumberOfZeros(int indexBitLength)
Expand Down