-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-573 fix calc #575
GH-573 fix calc #575
Conversation
It might not need to be aligned to the nearest power of two. I guess I just did that to make the buckets seem more evenly spaced, but it might just be as simple as I can also see that I've been adding 1 to all the indexes. Like this If I change my test a bit I'm actually getting another index out of bounds because of that package com.the_qa_company.qendpoint.core.util.disk;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.util.Random;
public class AbstractLongArrayTest {
@Test
public void updateEstimatedLocationArrayBucketSize() {
Random random = new Random();
AbstractLongArray longArray = new AbstractLongArray() {
@Override
public long get(long index) {
return Long.MAX_VALUE-index;
}
@Override
public long length() {
return AbstractLongArray.ESTIMATED_LOCATION_ARRAY_SIZE * 1024L* 16L;
}
@Override
public int sizeOf() {
return 0;
}
@Override
public void resize(long newSize) throws IOException {
}
@Override
public void clear() {
}
@Override
protected void innerSet(long index, long value) {
}
};
for (long i = 0; i < (AbstractLongArray.ESTIMATED_LOCATION_ARRAY_SIZE * 1024L) + 3; i++) {
testMaxValue(longArray, i);
}
for (long i = 1; i > 0 && i < (Long.MAX_VALUE - 1); i *= 2) {
testMaxValue(longArray, i);
}
testMaxValue(longArray, Long.MAX_VALUE);
System.out.println();
longArray.recalculateEstimatedValueLocation();
long estimatedLocation = longArray.getEstimatedLocation(Long.MAX_VALUE, -1 , Long.MAX_VALUE);
long estimatedLocationLowerBound = longArray.getEstimatedLocationLowerBound(Long.MAX_VALUE);
long estimatedLocationUpperBound = longArray.getEstimatedLocationUpperBound(Long.MAX_VALUE);
System.out.println(estimatedLocation);
System.out.println(estimatedLocationLowerBound);
System.out.println(estimatedLocationUpperBound);
}
private static void testMaxValue(AbstractLongArray longArray, long value) {
// if(value % (1024) == 0) System.out.println(value);
longArray.maxValue = value;
longArray.updateEstimatedLocationArrayBucketSize();
// longArray.recalculateEstimatedValueLocation();
long estimatedLocationArrayBucketSize = longArray.getEstimatedLocationArrayBucketSize();
Assert.assertTrue(estimatedLocationArrayBucketSize+"", estimatedLocationArrayBucketSize > 0 );
longArray.getEstimatedLocation(value, -1, Long.MAX_VALUE);
longArray.getEstimatedLocationLowerBound(value);
longArray.getEstimatedLocationUpperBound(value);
}
} |
…what faster to not use power of 2
Issue resolved (if any): #573
Description of this pull request:
@hmottestad I'm not really sure if it fixes the issue. I replaced everything to long, but the most important part is updateEstimatedLocationArrayBucketSize.
I think the estimatedLocationBucketSize value was too small for the highest value. I kept the nearest power of 2 alignment, but I don't see where it was used.
Please check all the lines before posting the pull request:
mvn formatter:format
on the backend,npm run format
on the frontend) before posting my pull request,mvn formatter:validate
to validate the formatting on the backend,npm run validate
on the frontend