Skip to content

Commit e8c9b30

Browse files
committed
WIP
1 parent b3390b9 commit e8c9b30

10 files changed

Lines changed: 535 additions & 924 deletions

include/aws/s3/private/aws_mmap.h

Lines changed: 0 additions & 67 deletions
This file was deleted.

include/aws/s3/private/s3_meta_request_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ struct aws_s3_meta_request {
287287

288288
/* The sending file context */
289289
struct aws_string *send_filepath;
290-
struct aws_mmap_context *send_file_mmap_context;
291290

292291
/* The receiving file handler */
293292
FILE *recv_file;

include/aws/s3/private/s3_parallel_input_stream.h

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,11 @@ struct aws_parallel_input_stream_vtable {
3535
/**
3636
* Read into the buffer in parallel.
3737
* The stream will split into parts and read each part in parallel.
38-
*
39-
* TODO: error handling:
40-
* - The stream reach end before all parts
41-
* - Failed to create a elg task to read
42-
* - Asyc related stuff as the original async stream (If we cannot fill the dest, we wait?)
43-
* - etc.
4438
*/
4539
struct aws_future_bool *(*read)(
4640
struct aws_parallel_input_stream *stream,
47-
size_t start_position,
48-
size_t end_position,
41+
size_t offset,
42+
size_t length,
4943
struct aws_byte_buf *dest);
5044
};
5145

@@ -78,42 +72,64 @@ AWS_S3_API
7872
struct aws_parallel_input_stream *aws_parallel_input_stream_release(struct aws_parallel_input_stream *stream);
7973

8074
/**
75+
* Read data from the stream into the destination buffer.
8176
*
82-
* @param stream
83-
* @param start_position
84-
* @param end_position
85-
* @param dest
86-
* @param split_num
87-
* @return AWS_S3_API struct*
77+
* @param stream The parallel input stream to read from
78+
* @param offset The starting offset in the stream to read from
79+
* @param length The number of bytes to read
80+
* @param dest The destination buffer to read into
81+
* @return A future that will be set to true when the read completes successfully,
82+
* or set to an error if the read fails
8883
*/
8984
AWS_S3_API
9085
struct aws_future_bool *aws_parallel_input_stream_read(
9186
struct aws_parallel_input_stream *stream,
92-
size_t start_position,
93-
size_t end_position,
87+
size_t offset,
88+
size_t length,
9489
struct aws_byte_buf *dest);
9590

91+
/**
92+
* Creates a new parallel input stream that reads from a file.
93+
* This stream uses an event loop group to perform file I/O operations asynchronously.
94+
*
95+
* @param allocator The allocator to use for memory allocation
96+
* @param file_name The name of the file to read from
97+
* @param reading_elg The event loop group to use for file I/O operations
98+
* @return A new parallel input stream that reads from the specified file
99+
*/
96100
AWS_S3_API
97101
struct aws_parallel_input_stream *aws_parallel_input_stream_new_from_file(
98102
struct aws_allocator *allocator,
99103
struct aws_byte_cursor file_name,
100104
struct aws_event_loop_group *reading_elg);
101105

102-
/****************** Open the file descriptor every time ***************************/
103-
struct aws_input_stream *aws_input_stream_new_from_parallel(
104-
struct aws_allocator *allocator,
105-
struct aws_parallel_input_stream *parallel_stream,
106-
uint64_t offset,
107-
size_t request_body_size);
108-
void aws_s3_part_streaming_input_stream_reset(struct aws_input_stream *stream);
106+
/****************** Adapters to convert parallel input stream to standard input stream ***************************/
109107

110-
/****************** Take mmap context ***************************/
111-
struct aws_input_stream *aws_input_stream_new_from_mmap_context(
108+
/**
109+
* Creates a new streaming input stream that reads from a parallel input stream.
110+
* This adapter allows using a parallel input stream with APIs that expect a standard input stream.
111+
* The adapter uses double-buffering to read ahead and provide efficient streaming.
112+
*
113+
* @param allocator The allocator to use for memory allocation
114+
* @param stream The parallel input stream to read from
115+
* @param offset The starting offset in the stream
116+
* @param request_body_size The total size to read
117+
* @return A new input stream that reads from the parallel input stream
118+
*/
119+
struct aws_input_stream *aws_input_stream_new_from_parallel_stream(
112120
struct aws_allocator *allocator,
113121
struct aws_parallel_input_stream *stream,
114122
uint64_t offset,
115123
size_t request_body_size);
116-
void aws_s3_mmap_part_streaming_input_stream_reset(struct aws_input_stream *stream);
124+
125+
/**
126+
* Resets the streaming input stream to start reading from the beginning again.
127+
* This allows reusing the same stream for multiple read operations.
128+
*
129+
* @param stream The streaming input stream to reset
130+
*/
131+
void aws_streaming_input_stream_reset(struct aws_input_stream *stream);
132+
117133
AWS_EXTERN_C_END
118134
AWS_POP_SANE_WARNING_LEVEL
119135

0 commit comments

Comments
 (0)