Class DocStoreClient
java.lang.Object
com.salesforce.multicloudj.docstore.client.DocStoreClient
DocStoreClient provides a unified interface for document/kv store operations across multiple
cloud providers.
This client supports various document operations such as create, read, update, delete (CRUD) operations along with Query interface on documents stored in cloud-based document databases like AWS DynamoDB, GCP Firestore, and Alibaba TableStore. The implementations also supports secondary indexes behind the scenes and uses them to optimize the queries.
Usage example:
DocStoreClient client = DocStoreClient.builder("aws")
.withRegion("us-west-2")
.build();
Person p = new Person("John", "Doe", 30);
Document doc = new Document(p);
client.create(doc);
client.query().where("age", 30).run();
The client supports input and output data in the form of Java POJOs and maps. The standard types supported are String, Number, Boolean, Date, List and Map. List and Maps are not supported for Alibaba tablestore.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for creating DocStoreClient instances with fluent configuration. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDocStoreClient(AbstractDocStore docStore) Protected constructor for DocStoreClient. -
Method Summary
Modifier and TypeMethodDescriptionvoidRetrieves multiple documents from the document store in a single batch operation.voidCreates or updates multiple documents in the document store in a single batch operation.Creates a new builder for DocStoreClient.voidclose()Closes the document store client and releases associated resources.voidCreates a new document in the document store.voidDeletes a document from the document store.voidRetrieves a document from the document store.Returns the underlying ActionList for advanced batch operations.voidCreates or updates a document in the document store.query()Creates a new Query instance for querying the document store.voidReplaces an existing document in the document store.voidUpdates specific fields of an existing document in the document store.
-
Field Details
-
docStore
-
-
Constructor Details
-
DocStoreClient
Protected constructor for DocStoreClient. Use the builder pattern to create instances.- Parameters:
docStore- the underlying document store implementation
-
-
Method Details
-
builder
Creates a new builder for DocStoreClient.- Parameters:
providerId- the cloud provider identifier (e.g., "aws", "gcp-firestore", "ali")- Returns:
- a new DocStoreClientBuilder instance
-
create
Creates a new document in the document store. This operation will fail if a document with the same key already exists.- Parameters:
document- the document to create, must have a valid key
-
replace
Replaces an existing document in the document store. This operation will fail if the document does not exist.- Parameters:
document- the document to replace, must have a valid key
-
put
Creates or updates a document in the document store. This operation will create the document if it doesn't exist, or update it if it does.- Parameters:
document- the document to put, must have a valid key
-
delete
Deletes a document from the document store. This operation is idempotent - it will not fail if the document doesn't exist.- Parameters:
document- the document to delete, must have a valid key
-
get
Retrieves a document from the document store. The document input should have a valid key. The retrieved data is stored in the supplied document.- Parameters:
document- the document to retrieve, must have a valid key. The result will be stored in this documentfieldPath- optional field paths to retrieve specific fields only. If not provided, all fields are retrieved
-
update
Updates specific fields of an existing document in the document store. This operation is not yet supported and will throw an UnSupportedOperationException.- Parameters:
document- the document to update, must have a valid keymods- the field modifications to apply
-
batchGet
Retrieves multiple documents from the document store in a single batch operation. This is more efficient than multiple individual get operations. The retrieved data is stored in the supplied documents.- Parameters:
documents- the list of documents to retrieve, each must have a valid key. Results will be stored in these documents
-
batchPut
Creates or updates multiple documents in the document store in a single batch operation. This is more efficient than multiple individual put operations. Each document will be created if it doesn't exist, or updated if it does.- Parameters:
documents- the list of documents to put, each must have a valid key
-
close
public void close()Closes the document store client and releases associated resources. After calling this method, the client should not be used for further operations. -
getActions
Returns the underlying ActionList for advanced batch operations. This allows for fine-grained control over batch operations and mixing different operation types.- Returns:
- the ActionList instance for building custom batch operations
-
query
Creates a new Query instance for querying the document store. This allows for complex queries with filters, sorting, and pagination.- Returns:
- a new Query instance for building and executing queries
-