Skip to content

Conversation

@KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Nov 18, 2025

Description

This PR adds Cloud Storage support to the Object Storage adapter.

Related issues and/or PRs

Changes made

  • Added an ObjectStorageWrapper implementation for Cloud Storage.
  • Added unit tests.
  • Added a GitHub workflow for integration tests.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Added Google Cloud Storage adapter.

@KodaiD KodaiD self-assigned this Nov 18, 2025
@KodaiD KodaiD added the enhancement New feature or request label Nov 18, 2025
@gemini-code-assist
Copy link
Contributor

It looks like you might be trying to invoke a command. If you'd like me to perform a code review, please use /gemini review. If you'd like a summary of the pull request, please use /gemini summary. You can also type /gemini help to see a list of all available commands.

Comment on lines -155 to +168
assertThatCode(() -> wrapper.update(objectKey, "some-object", "some-version"))
assertThatCode(() -> wrapper.update(objectKey, "some-object", "123456789"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since Cloud Storage assumes long for their versions, text that is not compatible with long causes the following error:

java.lang.NumberFormatException: For input string: "wrong-version"

}

char[] charArray = new char[(int) parallelUploadThresholdInBytes];
char[] charArray = new char[(int) parallelUploadThresholdInBytes + 1];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The object size has been changed to ensure that the multipart upload was triggered.


@ThreadSafe
public class CloudStorageWrapper implements ObjectStorageWrapper {
public static final int BATCH_DELETE_SIZE_LIMIT = 100;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You should not include more than 100 calls in a single batch request.

Reference: https://cloud.google.com/storage/docs/batch

@KodaiD
Copy link
Contributor Author

KodaiD commented Nov 18, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Google Cloud Storage as a backend for the Object Storage adapter. The changes include adding a new CloudStorageWrapper, its configuration, and corresponding unit and integration tests. The implementation is comprehensive and follows the existing patterns for other object storage providers. I've found a few issues, including a potential NullPointerException if credentials aren't provided, incorrect exception handling in batch deletes, a copy-paste error in the CloudStorageProvider, and a minor issue in the build configuration. Overall, this is a great addition, and with these fixes, it will be a robust implementation.

@KodaiD
Copy link
Contributor Author

KodaiD commented Nov 18, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Google Cloud Storage to the Object Storage adapter, which is a significant and well-executed enhancement. The changes include a new CloudStorageWrapper implementation, its corresponding configuration class, and a service provider. A notable improvement is the refactoring of the ObjectStorageConfig interface, which enhances abstraction and has been consistently applied to the existing Blob Storage and S3 implementations. Error handling has been improved, particularly in the close() methods of ObjectStorage and ObjectStorageAdmin. The addition of comprehensive unit and integration tests for the new Cloud Storage functionality is commendable. Overall, the pull request is of high quality. I have one suggestion to refine the exception handling in the CloudStorageWrapper constructor for better clarity.

@KodaiD KodaiD marked this pull request as ready for review November 18, 2025 04:29
Copilot AI review requested due to automatic review settings November 18, 2025 04:29
Copilot finished reviewing on behalf of KodaiD November 18, 2025 04:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds Google Cloud Storage support as a new object storage adapter for ScalarDB, implementing the ObjectStorageWrapper interface to enable Cloud Storage as a backend storage option alongside existing adapters (S3, Azure Blob Storage).

Key Changes:

  • Implemented CloudStorageWrapper with full CRUD operations using Google Cloud Storage API
  • Added configuration support via CloudStorageConfig using DatabaseConfig properties
  • Extended ObjectStorageWrapper interface to support exceptions in close() method and added documentation for deleteByPrefix atomicity constraints

Reviewed Changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
CloudStorageWrapper.java Core implementation of Cloud Storage adapter with get, insert, update, delete operations using Google Cloud Storage client
CloudStorageConfig.java Configuration class mapping DatabaseConfig properties to Cloud Storage settings (project ID, bucket, credentials)
CloudStorageProvider.java Service provider implementation for Cloud Storage adapter discovery
CloudStorageErrorCode.java Enum defining Cloud Storage HTTP error codes for error handling
CloudStorageWrapperTest.java Comprehensive unit tests for CloudStorageWrapper operations
CloudStorageConfigTest.java Unit tests for configuration validation and property loading
ObjectStorageWrapper.java Updated interface with close() exception handling and deleteByPrefix documentation
ObjectStorageWrapperException.java Added constructor accepting message-only for improved exception handling
PreconditionFailedException.java Added constructor accepting message-only for simpler exception creation
ObjectStorageConfig.java Removed getUsername() method from interface (moved to implementation classes)
S3Config.java Moved getUsername() from interface override to implementation-specific method
BlobStorageConfig.java Moved getUsername() from interface override to implementation-specific method
ObjectStorageWrapperFactory.java Added factory support for CloudStorageWrapper instantiation
ObjectStorageUtils.java Added utility support for CloudStorageConfig creation
ObjectStorage.java Updated close() to handle ObjectStorageWrapperException with logging
ObjectStorageAdmin.java Updated close() to handle ObjectStorageWrapperException with logging
ObjectStorageWrapperIntegrationTest.java Added Cloud Storage support and test data adjustments for numeric version strings
ObjectStorageWrapperLargeObjectWriteIntegrationTest.java Added Cloud Storage parallel upload configuration and test data size adjustment
ObjectStorageEnv.java Added isCloudStorage() helper for test environment detection
core/build.gradle Added google-cloud-storage dependency and formatting improvements
build.gradle Added googleCloudStorageVersion property (2.60.0)
.github/workflows/object-storage-adapter-check.yaml Added Cloud Storage integration test workflow and fixed S3 artifact naming
META-INF/services/com.scalar.db.api.DistributedStorageProvider Registered CloudStorageProvider for service discovery

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KodaiD KodaiD requested review from a team, Torch3333, brfrn169, feeblefakie and komamitsu and removed request for a team November 18, 2025 06:12
return projectId;
}

public Credentials getCredentials() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should consider a more secure approach for production. I will address it in another PR.

Comment on lines -229 to +232
systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")})
systemProperties(System.getProperties().findAll { it.key.toString().startsWith("scalardb") })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The formatter adds white spaces. Since other tasks in this file also use this style, I've kept this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant