Skip to content

feat: introduce new BlobWriteSession #2123

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

Merged
merged 5 commits into from
Jul 25, 2023

Conversation

BenWhitehead
Copy link
Collaborator

When writing a new Blob to GCS, there are secondary session related state and actions which can't be represented by WriteChannel.

BlobWriteSession provides a new construct to allow retrieving the resultant object which is created after the WritableByteChannel is closed.

Along with the new session, configuration for this is now performed at the StorageOptions level where cross session considerations can influence the implementation of the returned session. The configurable option present for this new StorageWriterConfig is chunkSize. In the future new configurations will be added with their corresponding options.

For example, in a future release it will be possible to change from in memory buffering to instead buffer to disk thereby reducing heap usage.

@BenWhitehead BenWhitehead added the owlbot:ignore instruct owl-bot to ignore a PR label Jul 17, 2023
@BenWhitehead BenWhitehead requested a review from a team as a code owner July 17, 2023 18:59
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. labels Jul 17, 2023
writer.newLazyWriteChannel().getSession();
return new DecoratedWritableByteChannelSession<>(session, d);
}
return CrossTransportUtils.throwGrpcOnly(DefaultStorageWriterConfig.class, "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should methodName be empty or writeSession?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. This is an internal only method that will never be on the public api. This error fall through is to catch if somehow someone does manage to call this in a way they shouldn't it will error.

GrpcStorageOptions options,
StorageClient storageClient,
WriterFactory writerFactory,
Opts<UserProject> defaultOpts) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it defaultOpts or globalOpts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both? If a UserProject opt is specified in one of the methods that will take precidence, if it isn't specified any possible value in here will be used.

this.chunkSize = chunkSize;
}

public int getChunkSize() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this include other properties such as upload_id and offset?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, this is the singleton instance that is used to configure all BlobWriteSessions for the whole client. If we were to expose uploadId & offset those would more likely become part of the session.

@BenWhitehead BenWhitehead force-pushed the write-acceleration/m1/1/BlobWriteSession branch from ce7ff3d to 16d7363 Compare July 19, 2023 15:55
When writing a new Blob to GCS, there are secondary session related state and actions which can't be represented by WriteChannel.

BlobWriteSession provides a new construct to allow retrieving the resultant object which is created after the WritableByteChannel is closed.

Along with the new session, configuration for this is now performed at the StorageOptions level where cross session considerations can influence the implementation of the returned session. The configurable option present for this new StorageWriterConfig is chunkSize. In the future new configurations will be added with their corresponding options.

For example, in a future release it will be possible to change from in memory buffering to instead buffer to disk thereby reducing heap usage.
@BenWhitehead BenWhitehead force-pushed the write-acceleration/m1/1/BlobWriteSession branch from 16d7363 to 7ad02f5 Compare July 24, 2023 21:50
@BenWhitehead BenWhitehead requested a review from a team as a code owner July 24, 2023 21:50
@generated-files-bot

This comment was marked as outdated.

@BenWhitehead BenWhitehead force-pushed the write-acceleration/m1/1/BlobWriteSession branch from 7ad02f5 to 48d96c5 Compare July 24, 2023 21:50
@BenWhitehead BenWhitehead merged commit e0191b5 into main Jul 25, 2023
@BenWhitehead BenWhitehead deleted the write-acceleration/m1/1/BlobWriteSession branch July 25, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. owlbot:ignore instruct owl-bot to ignore a PR size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants