Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature: Expose API to configure chunk size for java binding #5421

Closed
BaurzhanSakhariev opened this issue Dec 17, 2024 · 2 comments · Fixed by #5422
Closed

new feature: Expose API to configure chunk size for java binding #5421

BaurzhanSakhariev opened this issue Dec 17, 2024 · 2 comments · Fixed by #5422
Labels
enhancement New feature or request

Comments

@BaurzhanSakhariev
Copy link
Contributor

BaurzhanSakhariev commented Dec 17, 2024

Feature Description

Ability to configure chunk size for Operator

Problem and Solution

OperatorOutputStream uses hardcoded chunk size which leads to BlockCountExceedsLimit error when uploading a large file using azblob service. Increasing chunk size helps to have fewer blocks and avoid this error.

Also, upload time decreased significantly with buffer size 10x of the current size.

I used a test

@Test
public void testLargeFile() {
  final String path = UUID.randomUUID().toString();
  final Random random = new Random();
  final int size = 16384 * 10; // 10 x OperatorOutputStream.MAX_BYTES (10 flushes per write)
  final byte[] content = new byte[size];
  random.nextBytes(content);
  try (Operator op = op(); OperatorOutputStream operatorOutputStream = op.createOutputStream(path)) {
      for (int i = 0; i < 20000; i++) { // More iterations in case BlockCountExceedsLimit doesn't pop up exactly after 100K blocks.
          operatorOutputStream.write(content);
      }
  } catch (IOException e) {
      throw new RuntimeException(e);
  }
}

against a real Azure container and got an error after exactly 100K iterations.

Then manually changed OperatorOutputStream.MAX_BYTES to make it 10x.
Test passed and file has been uploaded to the container.

Additional Context

#5420 and crate/crate#17136

@Xuanwo
Copy link
Member

Xuanwo commented Dec 18, 2024

Thank you @tisonkun for fixing this!

@BaurzhanSakhariev
Copy link
Contributor Author

This will be part of the 0.51.0, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants