Skip to content

Conversation

@mooc9988
Copy link
Contributor

No description provided.

… use pooled bytebuffer;

Signed-off-by: Curtis Wan <wcy9988@163.com>
… use pooled bytebuffer;

Signed-off-by: Curtis Wan <wcy9988@163.com>
@mooc9988 mooc9988 requested a review from superhx September 10, 2023 12:34
long indexBlockPosition = objectTailBuf.getLong(objectTailBuf.readableBytes() - 48);
int indexBlockSize = objectTailBuf.getInt(objectTailBuf.readableBytes() - 40);
if (indexBlockPosition + objectTailBuf.readableBytes() < objectSize) {
if (indexBlockPosition + indexBlockSize + 48 < objectSize) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace magic value with named const value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the next commit.

if (cachedBuf == null) {
// Case 1: create cache and add as the first item.
if (targetSize < minPartSize) {
cachedBuf = ByteBufAllocator.DEFAULT.compositeBuffer();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ByteBufAlloc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the next commit.

// cachedBuf not null
long combinedSize = cachedBufSize + targetSize;

if (combinedSize <= 2 * minPartSize) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2 * minPartSize

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually used to limit range reading. More comments will be added to explain this.

}

@Override
public void copyWrite(String sourcePath, long start, long end) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract write/copyWrite common code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled in the next commit.

if (targetSize < minPartSize) {
cachedBuf = ByteBufAllocator.DEFAULT.compositeBuffer();
cachedBufSize = targetSize;
cachedBufLastAddCf = CompletableFuture.completedFuture(part).thenAccept(buf -> cachedBuf.addComponent(true, buf));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More readable name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more comments are added for it.

// Case 5: fill cachedBuf with source until it reaches minPartSize. Upload the cache and the rest of the source.
cachedBufLastAddCf = cachedBufLastAddCf
.thenRun(() -> cachedBuf.addComponent(true, part.slice(part.readerIndex(), (int) (minPartSize - cachedBufSize)).retain()));
handleWriteFuturePart(cachedBufLastAddCf, cachedBuf, System.nanoTime());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why two handleWriteFuturePart

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one is needed. Fixed in the next commit.

Signed-off-by: Curtis Wan <wcy9988@163.com>
@superhx superhx merged commit b628275 into develop Sep 11, 2023
@superhx superhx deleted the feat_add_s3_upload_limit branch September 11, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants