Skip to content

Commit

Permalink
Update variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 committed Dec 8, 2023
1 parent dceaf6c commit a0b9083
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/aws/s3/private/s3_auto_ranged_get.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct aws_s3_auto_ranged_get {
uint32_t initial_message_has_if_match_header : 1;

struct aws_string *etag;
uint64_t size_hint;
uint64_t object_size_hint;
};

AWS_EXTERN_C_BEGIN
Expand Down
10 changes: 8 additions & 2 deletions include/aws/s3/s3_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,14 @@ struct aws_s3_meta_request_options {
*/
struct aws_s3_meta_request_resume_token *resume_token;

// TODO: agonize over name and documentation
uint64_t size_hint;
/*
* Optional.
* Object size hint in bytes.
* This hint helps optimize downloads for small (less than or equal to part_size) or large files.
* This is just used as an estimate, so it's okay to provide an approximate value if the exact size is unknown.
* If not set, the client will assume a large file by default.
*/
uint64_t object_size_hint;
};

/* Result details of a meta request.
Expand Down
2 changes: 1 addition & 1 deletion source/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static struct aws_error_info s_errors[] = {
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_INVALID_MEMORY_LIMIT_CONFIG, "Specified memory configuration is invalid for the system. "
"Memory limit should be at least 1GiB. Part size and max part size should be smaller than memory limit."),
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3EXPRESS_CREATE_SESSION_FAILED, "CreateSession call failed when signing with S3 Express."),
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_INTERNAL_PART_SIZE_MISMATCH_RETRYING_WITH_RANGE, "part_size mismatch, possibly due to bad size_hint. Retrying with Range instead of partGet."),
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_INTERNAL_PART_SIZE_MISMATCH_RETRYING_WITH_RANGE, "part_size mismatch, possibly due to wrong object_size_hint. Retrying with Range instead of partGet."),

};
/* clang-format on */
Expand Down
6 changes: 3 additions & 3 deletions source/s3_auto_ranged_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct aws_s3_meta_request *aws_s3_meta_request_auto_ranged_get_new(
auto_ranged_get->initial_message_has_range_header = aws_http_headers_has(headers, g_range_header_name);
auto_ranged_get->initial_message_has_if_match_header = aws_http_headers_has(headers, g_if_match_header_name);
auto_ranged_get->synced_data.first_part_size = auto_ranged_get->base.part_size;
auto_ranged_get->size_hint = options->size_hint;
auto_ranged_get->object_size_hint = options->object_size_hint;

AWS_LOGF_DEBUG(
AWS_LS_S3_META_REQUEST, "id=%p Created new Auto-Ranged Get Meta Request.", (void *)&auto_ranged_get->base);
Expand Down Expand Up @@ -133,10 +133,10 @@ static enum aws_s3_auto_ranged_get_request_type s_s3_get_discovers_object_size_r
if (!meta_request->checksum_config.validate_response_checksum)
return AWS_S3_AUTO_RANGE_GET_REQUEST_TYPE_GET_RANGE;

/* If the size_hint indicates that it is a small one part file, then try to get the file directly
/* If the object_size_hint indicates that it is a small one part file, then try to get the file directly
* TODO: Bypass memory limiter so that we don't overallocate memory for small files
*/
if (auto_ranged_get->size_hint > 0 && auto_ranged_get->size_hint <= meta_request->part_size)
if (auto_ranged_get->object_size_hint > 0 && auto_ranged_get->object_size_hint <= meta_request->part_size)
return AWS_S3_AUTO_RANGE_GET_REQUEST_TYPE_GET_PART_NUMBER;

/* Otherwise, do a headObject so that we can validate checksum if the file was uploaded as a single part */
Expand Down
14 changes: 7 additions & 7 deletions tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3648,7 +3648,7 @@ static int s_test_s3_download_empty_file_with_checksum(struct aws_allocator *all
.object_path = object_path,
},
.finish_callback = s_s3_test_validate_checksum,
.size_hint = 1 /* pass a size_hint > 0 so that the request goes through the getPart flow */,
.object_size_hint = 1 /* pass a object_size_hint > 0 so that the request goes through the getPart flow */,
};
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &get_options, NULL));

Expand Down Expand Up @@ -3715,7 +3715,7 @@ static int s_test_s3_download_single_part_file_with_checksum(struct aws_allocato
.object_path = object_path,
},
.finish_callback = s_s3_test_validate_checksum,
.size_hint = MB_TO_BYTES(object_size_mb),
.object_size_hint = MB_TO_BYTES(object_size_mb),
};

/* will do headRequest */
Expand Down Expand Up @@ -3744,12 +3744,12 @@ static int s_test_s3_download_single_part_file_with_checksum(struct aws_allocato
client = aws_s3_client_release(client);
tester.bound_to_client = false;

/*** GET FILE with part_size < file_size and wrong size_hint ***/
/*** GET FILE with part_size < file_size and wrong object_size_hint ***/
client_options.part_size = MB_TO_BYTES(3);

ASSERT_SUCCESS(aws_s3_tester_client_new(&tester, &client_options, &client));
get_options.client = client;
get_options.size_hint = MB_TO_BYTES(1);
get_options.object_size_hint = MB_TO_BYTES(1);
/* will do getPart first, cancel it and then rangedGet */
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &get_options, NULL));
client = aws_s3_client_release(client);
Expand Down Expand Up @@ -3816,7 +3816,7 @@ static int s_test_s3_download_multipart_file_with_checksum(struct aws_allocator
{
.object_path = object_path,
},
.size_hint = MB_TO_BYTES(object_size_mb),
.object_size_hint = MB_TO_BYTES(object_size_mb),
};

/* will do HeadRequest first */
Expand Down Expand Up @@ -3845,8 +3845,8 @@ static int s_test_s3_download_multipart_file_with_checksum(struct aws_allocator
client = aws_s3_client_release(client);
tester.bound_to_client = false;

/*** GET FILE with with wrong size_hint ***/
get_options.size_hint = MB_TO_BYTES(1);
/*** GET FILE with with wrong object_size_hint ***/
get_options.object_size_hint = MB_TO_BYTES(1);
get_options.finish_callback = NULL;

/*** GET FILE with part_size < first_part_size***/
Expand Down
2 changes: 1 addition & 1 deletion tests/s3_tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ int aws_s3_tester_send_meta_request_with_options(
.message = options->message,
.checksum_config = &checksum_config,
.resume_token = options->put_options.resume_token,
.size_hint = options->size_hint,
.object_size_hint = options->object_size_hint,
};

if (options->mock_server) {
Expand Down
2 changes: 1 addition & 1 deletion tests/s3_tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ struct aws_s3_tester_meta_request_options {

uint32_t mrap_test : 1;

uint64_t size_hint;
uint64_t object_size_hint;
};

/* TODO Rename to something more generic such as "aws_s3_meta_request_test_data" */
Expand Down

0 comments on commit a0b9083

Please sign in to comment.