Skip to content

Commit 6a930f3

Browse files
committed
fixed length bug
1 parent e4a57b0 commit 6a930f3

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

server/src/main/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesProducer.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,13 +1253,14 @@ public void loadBlock(BlockLoader.SingletonLongBuilder builder, BlockLoader.Docs
12531253
}
12541254
} else {
12551255
// consume remaining
1256-
int length = ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE - firstBlockInIndex;
1257-
if (docs.count() < length) {
1258-
builder.appendLongs(currentBlock, firstBlockInIndex, docs.count());
1256+
int docsLength = docs.count() - offset;
1257+
int blockLength = ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE - firstBlockInIndex;
1258+
if (docsLength< blockLength) {
1259+
builder.appendLongs(currentBlock, firstBlockInIndex, docsLength);
12591260
return;
12601261
} else {
1261-
builder.appendLongs(currentBlock, firstBlockInIndex, length);
1262-
start = offset + length;
1262+
builder.appendLongs(currentBlock, firstBlockInIndex, blockLength);
1263+
start = offset + blockLength;
12631264
}
12641265
}
12651266

@@ -1358,13 +1359,14 @@ public void loadBlock(BlockLoader.TSSingletonOrdinalsBuilder builder, BlockLoade
13581359
}
13591360
} else {
13601361
// consume remaining
1361-
int length = ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE - firstBlockInIndex;
1362-
if (docs.count() < length) {
1363-
builder.appendOrds(currentBlock, firstBlockInIndex, docs.count());
1362+
int blockLength = ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE - firstBlockInIndex;
1363+
int docsLength = docs.count() - offset;
1364+
if (docsLength < blockLength) {
1365+
builder.appendOrds(currentBlock, firstBlockInIndex, docsLength);
13641366
return;
13651367
} else {
1366-
builder.appendOrds(currentBlock, firstBlockInIndex, length);
1367-
start = offset + length;
1368+
builder.appendOrds(currentBlock, firstBlockInIndex, blockLength);
1369+
start = offset + blockLength;
13681370
}
13691371
}
13701372

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/read/TSSingletonOrdinalsBuilder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public TSSingletonOrdinalsBuilder appendOrd(long ord) {
6161

6262
@Override
6363
public BlockLoader.TSSingletonOrdinalsBuilder appendOrds(long[] values, int from, int length) {
64-
System.arraycopy(values, from, ords, count, length);
64+
try {
65+
System.arraycopy(values, from, ords, count, length);
66+
} catch (ArrayIndexOutOfBoundsException e) {
67+
throw e;
68+
}
6569
count += length;
6670
return this;
6771
}

0 commit comments

Comments
 (0)