Skip to content

Commit b1d4b17

Browse files
committed
Test values near the size of a block
1 parent 80525bf commit b1d4b17

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

server/src/test/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesFormatTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@
6363
import java.util.function.Supplier;
6464
import java.util.stream.IntStream;
6565

66+
import static org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesFormat.MIN_BLOCK_SIZE_BYTES;
6667
import static org.elasticsearch.test.ESTestCase.randomAlphaOfLengthBetween;
6768
import static org.elasticsearch.test.ESTestCase.randomBoolean;
69+
import static org.elasticsearch.test.ESTestCase.randomFloat;
6870
import static org.elasticsearch.test.ESTestCase.randomFrom;
6971
import static org.elasticsearch.test.ESTestCase.randomIntBetween;
7072
import static org.hamcrest.Matchers.equalTo;
@@ -98,18 +100,21 @@ public void testBlockWiseBinarySparse() throws Exception {
98100
String hostnameField = "host.name";
99101
long baseTimestamp = 1704067200000L;
100102
String binaryField = "binary_field";
103+
boolean testVeryLargeValues = randomFloat() < 0.1;
101104

102105
var config = getTimeSeriesIndexWriterConfig(hostnameField, timestampField);
103106
try (var dir = newDirectory(); var iw = new IndexWriter(dir, config)) {
104107

105108
int maxBlocks = 4;
106-
int binaryDataSize = randomIntBetween(0, ES819TSDBDocValuesFormat.MIN_BLOCK_SIZE_BYTES * maxBlocks);
109+
int binaryDataSize = randomIntBetween(0, MIN_BLOCK_SIZE_BYTES * maxBlocks);
107110

108111
List<String> binaryValues = new ArrayList<>();
109112
int totalSize = 0;
110113
while (totalSize < binaryDataSize) {
111114
if (randomBoolean()) {
112-
String value = randomAlphaOfLengthBetween(0, 100);
115+
final String value = testVeryLargeValues
116+
? randomAlphaOfLengthBetween(MIN_BLOCK_SIZE_BYTES / 2, 2 * MIN_BLOCK_SIZE_BYTES)
117+
: randomAlphaOfLengthBetween(0, 50);
113118
binaryValues.add(value);
114119
totalSize += value.length();
115120
} else {
@@ -162,17 +167,21 @@ public void testBlockWiseBinaryDense() throws Exception {
162167
String hostnameField = "host.name";
163168
long baseTimestamp = 1704067200000L;
164169
String binaryField = "binary_field";
170+
boolean testVeryLargeValues = randomFloat() < 0.1;
165171

166172
var config = getTimeSeriesIndexWriterConfig(hostnameField, timestampField);
167173
try (var dir = newDirectory(); var iw = new IndexWriter(dir, config)) {
168174

169175
int maxBlocks = 4;
170-
int binaryDataSize = randomIntBetween(0, ES819TSDBDocValuesFormat.MIN_BLOCK_SIZE_BYTES * maxBlocks);
176+
int binaryDataSize = randomIntBetween(0, MIN_BLOCK_SIZE_BYTES * maxBlocks);
171177

172178
List<String> binaryValues = new ArrayList<>();
173179
int totalSize = 0;
174180
while (totalSize < binaryDataSize) {
175-
String value = randomAlphaOfLengthBetween(0, 100);
181+
final String value = testVeryLargeValues
182+
? randomAlphaOfLengthBetween(MIN_BLOCK_SIZE_BYTES / 2, 2 * MIN_BLOCK_SIZE_BYTES)
183+
: randomAlphaOfLengthBetween(0, 50);
184+
176185
binaryValues.add(value);
177186
totalSize += value.length();
178187
}

0 commit comments

Comments
 (0)