Skip to content

Commit f549472

Browse files
committed
Fixed- PackedArrayIndexFieldData.chooseStorageFormat compared to Long.MAX_VALUE instead of Long.MIN_VALUE
Also made the LongFieldDataTests.SINGLE_VALUED_SPARSE_RANDOM & LongFieldDataTests.MULTI_VALUED_SPARSE_RANDOM more sparse
1 parent 1d1ca3b commit f549472

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/org/elasticsearch/index/fielddata/plain/PackedArrayIndexFieldData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected CommonSettings.MemoryStorageFormat chooseStorageFormat(AtomicReader re
261261
}
262262
if (pageIndex == pageSize - 1) {
263263
// end of page, we now know enough to estimate memory usage
264-
if (pageMaxOrdinal == Long.MAX_VALUE) {
264+
if (pageMaxOrdinal == Long.MIN_VALUE) {
265265
// empty page - will use the null reader which just stores size
266266
pagedSingleValuesSize += RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.NUM_BYTES_INT);
267267

@@ -288,7 +288,7 @@ protected CommonSettings.MemoryStorageFormat chooseStorageFormat(AtomicReader re
288288
if (pageIndex > 0) {
289289
// last page estimation
290290
pageIndex++;
291-
if (pageMaxOrdinal == Long.MAX_VALUE) {
291+
if (pageMaxOrdinal == Long.MIN_VALUE) {
292292
// empty page - will use the null reader which just stores size
293293
pagedSingleValuesSize += RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.NUM_BYTES_INT);
294294

src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public long nextValue(Random r) {
281281
},
282282
SINGLE_VALUED_SPARSE_RANDOM {
283283
public int numValues(Random r) {
284-
return r.nextFloat() < 0.1f ? 1 : 0;
284+
return r.nextFloat() < 0.01 ? 1 : 0;
285285
}
286286

287287
@Override
@@ -291,7 +291,7 @@ public long nextValue(Random r) {
291291
},
292292
MULTI_VALUED_SPARSE_RANDOM {
293293
public int numValues(Random r) {
294-
return r.nextFloat() < 0.1f ? 1 + r.nextInt(5) : 0;
294+
return r.nextFloat() < 0.01f ? 1 + r.nextInt(5) : 0;
295295
}
296296

297297
@Override

0 commit comments

Comments
 (0)