This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-classloaders.git
The following commit(s) were added to refs/heads/main by this push:
new 9f91cfe buffer downloads (#36)
9f91cfe is described below
commit 9f91cfefbed125f0dd89ff12e0b1f274f1e474b1
Author: Keith Turner <[email protected]>
AuthorDate: Tue Jan 13 12:06:46 2026 -0800
buffer downloads (#36)
Co-authored-by: Christopher Tubbs <[email protected]>
---
.../org/apache/accumulo/classloader/lcc/util/LocalStore.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
index a55b695..4d819da 100644
---
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
+++
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
@@ -27,6 +27,8 @@ import static java.nio.file.StandardOpenOption.WRITE;
import static java.util.Objects.requireNonNull;
import static org.apache.accumulo.classloader.lcc.util.LccUtils.DIGESTER;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
@@ -292,11 +294,15 @@ public final class LocalStore {
}
}
+ private static final int DL_BUFF_SIZE = 1024 * 1024;
+
private void downloadFile(FileResolver source, Path tempPath, Resource
resource) {
// CREATE_NEW ensures the temporary file name is unique for this attempt
- // SYNC ensures file integrity on each write, in case of system failure
- try (var in = source.getInputStream();
- var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+ // SYNC ensures file integrity on each write, in case of system failure.
Buffering minimizes
+ // system calls te read/write data which minimizes the number of syncs.
+ try (var in = new BufferedInputStream(source.getInputStream(),
DL_BUFF_SIZE);
+ var out = new BufferedOutputStream(Files.newOutputStream(tempPath,
CREATE_NEW, WRITE, SYNC),
+ DL_BUFF_SIZE)) {
in.transferTo(out);
} catch (IOException e) {
throw new UncheckedIOException(e);