Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,19 @@ protected T createTestInstance(String name, Map<String, Object> metadata, Intern
final int precision = randomPrecision();
int size = randomNumberOfBuckets();
List<InternalGeoGridBucket> buckets = new ArrayList<>(size);
final List<Long> seen = new ArrayList<>(size);
int finalSize = 0;
for (int i = 0; i < size; i++) {
double latitude = randomDoubleBetween(-90.0, 90.0, false);
double longitude = randomDoubleBetween(-180.0, 180.0, false);

long hashAsLong = longEncode(longitude, latitude, precision);
buckets.add(createInternalGeoGridBucket(hashAsLong, randomInt(IndexWriter.MAX_DOCS), aggregations));
if (seen.contains(hashAsLong) == false) { // make sure we don't add twice the same bucket
buckets.add(createInternalGeoGridBucket(hashAsLong, randomInt(IndexWriter.MAX_DOCS), aggregations));
seen.add(hashAsLong);
finalSize++;
}
}
return createInternalGeoGrid(name, size, buckets, metadata);
return createInternalGeoGrid(name, finalSize, buckets, metadata);
}

@Override
Expand Down