Skip to content

Commit 99a9968

Browse files
committed
COPY_BUFFER_SIZE
1 parent 391633f commit 99a9968

File tree

1 file changed

+4
-2
lines changed
  • x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache

1 file changed

+4
-2
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/CacheDirectory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
*/
3232
public class CacheDirectory extends FilterDirectory {
3333

34+
private static final int COPY_BUFFER_SIZE = 8192;
35+
3436
private final CacheService cacheService;
3537
private final Path cacheDir;
3638

@@ -179,7 +181,7 @@ int readCacheFile(FileChannel fc, long end, long position, byte[] buffer, int of
179181
@SuppressForbidden(reason = "Use positional writes on purpose")
180182
void writeCacheFile(FileChannel fc, long start, long end) throws IOException {
181183
assert assertFileChannelOpen(fc);
182-
final byte[] copyBuffer = new byte[Math.toIntExact(Math.min(8192L, end - start))];
184+
final byte[] copyBuffer = new byte[Math.toIntExact(Math.min(COPY_BUFFER_SIZE, end - start))];
183185
try (IndexInput input = in.openInput(fileName, ioContext)) {
184186
if (start > 0) {
185187
input.seek(start);
@@ -242,7 +244,7 @@ public String toString() {
242244
}
243245

244246
private int readDirectly(long start, long end, byte[] buffer, int offset) throws IOException {
245-
final byte[] copyBuffer = new byte[Math.toIntExact(Math.min(8192L, end - start))];
247+
final byte[] copyBuffer = new byte[Math.toIntExact(Math.min(COPY_BUFFER_SIZE, end - start))];
246248

247249
int bytesCopied = 0;
248250
try (IndexInput input = in.openInput(fileName, ioContext)) {

0 commit comments

Comments
 (0)