Skip to content

Commit

Permalink
Merge branch 'main' into add-css-matrix-8.17
Browse files Browse the repository at this point in the history
  • Loading branch information
kosabogi authored Dec 12, 2024
2 parents 502bcbc + 80a1a6f commit cb78022
Show file tree
Hide file tree
Showing 5 changed files with 661 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.apache.lucene.store.ByteBuffersDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FilterIndexInput;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
Expand Down Expand Up @@ -267,17 +268,47 @@ public void testSkipBytes() throws Exception {
skipBytesExpected
);

IndexInput input = dir.openInput("test", IOContext.DEFAULT);
InputStreamIndexInput is = new InputStreamIndexInput(input, limit);
var countingInput = new CountingReadBytesIndexInput("test", dir.openInput("test", IOContext.DEFAULT));
InputStreamIndexInput is = new InputStreamIndexInput(countingInput, limit);
is.readNBytes(initialReadBytes);
assertThat(is.skip(skipBytes), equalTo((long) skipBytesExpected));
long expectedActualInitialBytesRead = Math.min(Math.min(initialReadBytes, limit), bytes);
assertThat(countingInput.getBytesRead(), equalTo(expectedActualInitialBytesRead));

int remainingBytes = Math.min(bytes, limit) - seekExpected;
for (int i = seekExpected; i < seekExpected + remainingBytes; i++) {
assertThat(is.read(), equalTo(i));
}
assertThat(countingInput.getBytesRead(), equalTo(expectedActualInitialBytesRead + remainingBytes));
}

protected static class CountingReadBytesIndexInput extends FilterIndexInput {
private long bytesRead = 0;

public CountingReadBytesIndexInput(String resourceDescription, IndexInput in) {
super(resourceDescription, in);
}

@Override
public byte readByte() throws IOException {
long filePointerBefore = getFilePointer();
byte b = super.readByte();
bytesRead += getFilePointer() - filePointerBefore;
return b;
}

@Override
public void readBytes(byte[] b, int offset, int len) throws IOException {
long filePointerBefore = getFilePointer();
super.readBytes(b, offset, len);
bytesRead += getFilePointer() - filePointerBefore;
}

public long getBytesRead() {
return bytesRead;
}
};

public void testReadZeroShouldReturnZero() throws IOException {
try (Directory dir = new ByteBuffersDirectory()) {
try (IndexOutput output = dir.createOutput("test", IOContext.DEFAULT)) {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/security/qa/multi-cluster/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
clusterModules project(':x-pack:plugin:enrich')
clusterModules project(':x-pack:plugin:autoscaling')
clusterModules project(':x-pack:plugin:ml')
clusterModules project(xpackModule('ilm'))
clusterModules(project(":modules:ingest-common"))
}

Expand Down
Loading

0 comments on commit cb78022

Please sign in to comment.