Skip to content

Commit 107e63e

Browse files
committed
expose the force dynamic size
1 parent b3e15c4 commit 107e63e

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/main/java/software/amazon/awssdk/crt/s3/S3Client.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ public S3MetaRequest makeMetaRequest(S3MetaRequestOptions options) {
220220
fioOptionsSet,
221221
shouldStream,
222222
diskThroughputGbps,
223-
directIo);
223+
directIo,
224+
options.getForceDynamicPartSize());
224225

225226
metaRequest.setMetaRequestNativeHandle(metaRequestNativeHandle);
226227

@@ -299,5 +300,6 @@ private static native long s3ClientMakeMetaRequest(long clientId, S3MetaRequest
299300
boolean fioOptionsSet,
300301
boolean shouldStream,
301302
double diskThroughputGbps,
302-
boolean directIo);
303+
boolean directIo,
304+
boolean forceDynamicPartSize);
303305
}

src/main/java/software/amazon/awssdk/crt/s3/S3MetaRequestOptions.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private static Map<Integer, MetaRequestType> buildEnumMapping() {
9696
private ResumeToken resumeToken;
9797
private Long objectSizeHint;
9898
private FileIoOptions fileIoOptions;
99+
private boolean forceDynamicPartSize = false;
99100

100101
public S3MetaRequestOptions withMetaRequestType(MetaRequestType metaRequestType) {
101102
this.metaRequestType = metaRequestType;
@@ -472,4 +473,20 @@ public S3MetaRequestOptions withFileIoOptions(FileIoOptions fileIoOptions) {
472473
public FileIoOptions getFileIoOptions() {
473474
return fileIoOptions;
474475
}
476+
477+
/**
478+
* WARNING: experimental/unstable.
479+
* Set this to force the dynamic default part_size regardless the part size set from client or meta request.
480+
* Set this to get the best performance under the memory constrain, especially for getting large objects.
481+
*
482+
* @param forceDynamicPartSize True to force the dynamic part size, False to use the part size set from client or meta request.
483+
* @return this
484+
*/
485+
public S3MetaRequestOptions withForceDynamicPartSize(boolean forceDynamicPartSize) {
486+
this.forceDynamicPartSize = forceDynamicPartSize;
487+
return this;
488+
}
489+
public boolean getForceDynamicPartSize() {
490+
return forceDynamicPartSize;
491+
}
475492
}

src/native/s3_client.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,8 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientMake
10011001
jboolean fio_options_set,
10021002
jboolean should_stream,
10031003
jdouble disk_throughput_gbps,
1004-
jboolean direct_io) {
1004+
jboolean direct_io,
1005+
jboolean force_dynamic_part_size) {
10051006
(void)jni_class;
10061007
aws_cache_jni_ids(env);
10071008

@@ -1147,6 +1148,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientMake
11471148
.recv_file_delete_on_failure = jni_response_file_delete_on_failure,
11481149
/* If fio options not set, let native code to decide the default instead */
11491150
.fio_opts = fio_options_set ? &fio_opts : NULL,
1151+
.force_dynamic_part_size = force_dynamic_part_size,
11501152
};
11511153

11521154
meta_request = aws_s3_client_make_meta_request(client, &meta_request_options);

0 commit comments

Comments
 (0)