Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.landawn.abacus.util.AsyncDynamoDBExecutor Maven / Gradle / Ivy
/*
* Copyright (C) 2015 HaiYang Li
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.landawn.abacus.util;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate;
import com.amazonaws.services.dynamodbv2.model.BatchGetItemRequest;
import com.amazonaws.services.dynamodbv2.model.BatchWriteItemRequest;
import com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult;
import com.amazonaws.services.dynamodbv2.model.Condition;
import com.amazonaws.services.dynamodbv2.model.DeleteItemRequest;
import com.amazonaws.services.dynamodbv2.model.DeleteItemResult;
import com.amazonaws.services.dynamodbv2.model.GetItemRequest;
import com.amazonaws.services.dynamodbv2.model.KeysAndAttributes;
import com.amazonaws.services.dynamodbv2.model.PutItemRequest;
import com.amazonaws.services.dynamodbv2.model.PutItemResult;
import com.amazonaws.services.dynamodbv2.model.QueryRequest;
import com.amazonaws.services.dynamodbv2.model.ScanRequest;
import com.amazonaws.services.dynamodbv2.model.UpdateItemRequest;
import com.amazonaws.services.dynamodbv2.model.UpdateItemResult;
import com.amazonaws.services.dynamodbv2.model.WriteRequest;
import com.landawn.abacus.DataSet;
import com.landawn.abacus.util.stream.Stream;
/**
* Asynchronous DynamoDBExecutor
.
*
* @since 0.8
*
* @author Haiyang Li
*/
public final class AsyncDynamoDBExecutor {
private final DynamoDBExecutor dbExecutor;
private final AsyncExecutor asyncExecutor;
AsyncDynamoDBExecutor(final DynamoDBExecutor dbExecutor, final AsyncExecutor asyncExecutor) {
this.dbExecutor = dbExecutor;
this.asyncExecutor = asyncExecutor;
}
public DynamoDBExecutor sync() {
return dbExecutor;
}
public ContinuableFuture> getItem(final String tableName, final Map key) {
return asyncExecutor.execute(new Callable>() {
@Override
public Map call() throws Exception {
return dbExecutor.getItem(tableName, key);
}
});
}
public ContinuableFuture> getItem(final String tableName, final Map key, final Boolean consistentRead) {
return asyncExecutor.execute(new Callable>() {
@Override
public Map call() throws Exception {
return dbExecutor.getItem(tableName, key, consistentRead);
}
});
}
public ContinuableFuture> getItem(final GetItemRequest getItemRequest) {
return asyncExecutor.execute(new Callable>() {
@Override
public Map call() throws Exception {
return dbExecutor.getItem(getItemRequest);
}
});
}
public ContinuableFuture getItem(final Class targetClass, final String tableName, final Map key) {
return asyncExecutor.execute(new Callable() {
@Override
public T call() throws Exception {
return dbExecutor.getItem(targetClass, tableName, key);
}
});
}
public ContinuableFuture getItem(final Class targetClass, final String tableName, final Map key,
final Boolean consistentRead) {
return asyncExecutor.execute(new Callable() {
@Override
public T call() throws Exception {
return dbExecutor.getItem(targetClass, tableName, key, consistentRead);
}
});
}
public ContinuableFuture getItem(final Class targetClass, final GetItemRequest getItemRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public T call() throws Exception {
return dbExecutor.getItem(targetClass, getItemRequest);
}
});
}
public ContinuableFuture>>> batchGetItem(final Map requestItems) {
return asyncExecutor.execute(new Callable>>>() {
@Override
public Map>> call() throws Exception {
return dbExecutor.batchGetItem(requestItems);
}
});
}
public ContinuableFuture>>> batchGetItem(final Map requestItems,
final String returnConsumedCapacity) {
return asyncExecutor.execute(new Callable>>>() {
@Override
public Map>> call() throws Exception {
return dbExecutor.batchGetItem(requestItems, returnConsumedCapacity);
}
});
}
public ContinuableFuture>>> batchGetItem(final BatchGetItemRequest batchGetItemRequest) {
return asyncExecutor.execute(new Callable>>>() {
@Override
public Map>> call() throws Exception {
return dbExecutor.batchGetItem(batchGetItemRequest);
}
});
}
public ContinuableFuture>> batchGetItem(final Class targetClass, final Map requestItems) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Map> call() throws Exception {
return dbExecutor.batchGetItem(targetClass, requestItems);
}
});
}
public ContinuableFuture>> batchGetItem(final Class targetClass, final Map requestItems,
final String returnConsumedCapacity) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Map> call() throws Exception {
return dbExecutor.batchGetItem(targetClass, requestItems, returnConsumedCapacity);
}
});
}
public ContinuableFuture>> batchGetItem(final Class targetClass, final BatchGetItemRequest batchGetItemRequest) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Map> call() throws Exception {
return dbExecutor.batchGetItem(targetClass, batchGetItemRequest);
}
});
}
public ContinuableFuture putItem(final String tableName, final Map item) {
return asyncExecutor.execute(new Callable() {
@Override
public PutItemResult call() throws Exception {
return dbExecutor.putItem(tableName, item);
}
});
}
public ContinuableFuture putItem(final String tableName, final Map item, final String returnValues) {
return asyncExecutor.execute(new Callable() {
@Override
public PutItemResult call() throws Exception {
return dbExecutor.putItem(tableName, item, returnValues);
}
});
}
public ContinuableFuture putItem(final PutItemRequest putItemRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public PutItemResult call() throws Exception {
return dbExecutor.putItem(putItemRequest);
}
});
}
// There is no too much benefit to add method for "Object entity"
// And it may cause error because the "Object" is ambiguous to any type.
ContinuableFuture putItem(final String tableName, final Object entity) {
return asyncExecutor.execute(new Callable() {
@Override
public PutItemResult call() throws Exception {
return dbExecutor.putItem(tableName, entity);
}
});
}
// There is no too much benefit to add method for "Object entity"
// And it may cause error because the "Object" is ambiguous to any type.
ContinuableFuture putItem(final String tableName, final Object entity, final String returnValues) {
return asyncExecutor.execute(new Callable() {
@Override
public PutItemResult call() throws Exception {
return dbExecutor.putItem(tableName, entity, returnValues);
}
});
}
public ContinuableFuture batchWriteItem(final Map> requestItems) {
return asyncExecutor.execute(new Callable() {
@Override
public BatchWriteItemResult call() throws Exception {
return dbExecutor.batchWriteItem(requestItems);
}
});
}
public ContinuableFuture batchWriteItem(final BatchWriteItemRequest batchWriteItemRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public BatchWriteItemResult call() throws Exception {
return dbExecutor.batchWriteItem(batchWriteItemRequest);
}
});
}
public ContinuableFuture updateItem(final String tableName, final Map key,
final Map attributeUpdates) {
return asyncExecutor.execute(new Callable() {
@Override
public UpdateItemResult call() throws Exception {
return dbExecutor.updateItem(tableName, key, attributeUpdates);
}
});
}
public ContinuableFuture updateItem(final String tableName, final Map key,
final Map attributeUpdates, final String returnValues) {
return asyncExecutor.execute(new Callable() {
@Override
public UpdateItemResult call() throws Exception {
return dbExecutor.updateItem(tableName, key, attributeUpdates, returnValues);
}
});
}
public ContinuableFuture updateItem(final UpdateItemRequest updateItemRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public UpdateItemResult call() throws Exception {
return dbExecutor.updateItem(updateItemRequest);
}
});
}
public ContinuableFuture deleteItem(final String tableName, final Map key) {
return asyncExecutor.execute(new Callable() {
@Override
public DeleteItemResult call() throws Exception {
return dbExecutor.deleteItem(tableName, key);
}
});
}
public ContinuableFuture deleteItem(final String tableName, final Map key, final String returnValues) {
return asyncExecutor.execute(new Callable() {
@Override
public DeleteItemResult call() throws Exception {
return dbExecutor.deleteItem(tableName, key, returnValues);
}
});
}
public ContinuableFuture deleteItem(final DeleteItemRequest deleteItemRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public DeleteItemResult call() throws Exception {
return dbExecutor.deleteItem(deleteItemRequest);
}
});
}
public ContinuableFuture>> list(final QueryRequest queryRequest) {
return asyncExecutor.execute(new Callable>>() {
@Override
public List> call() throws Exception {
return dbExecutor.list(queryRequest);
}
});
}
public ContinuableFuture> list(final Class targetClass, final QueryRequest queryRequest) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return dbExecutor.list(targetClass, queryRequest);
}
});
}
public ContinuableFuture query(final QueryRequest queryRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public DataSet call() throws Exception {
return dbExecutor.query(queryRequest);
}
});
}
public ContinuableFuture query(final Class targetClass, final QueryRequest queryRequest) {
return asyncExecutor.execute(new Callable() {
@Override
public DataSet call() throws Exception {
return dbExecutor.query(targetClass, queryRequest);
}
});
}
public ContinuableFuture>> stream(final QueryRequest queryRequest) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Stream> call() throws Exception {
return dbExecutor.stream(queryRequest);
}
});
}
public ContinuableFuture> stream(final Class targetClass, final QueryRequest queryRequest) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return dbExecutor.stream(targetClass, queryRequest);
}
});
}
public ContinuableFuture>> scan(final String tableName, final List attributesToGet) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Stream> call() throws Exception {
return dbExecutor.scan(tableName, attributesToGet);
}
});
}
public ContinuableFuture>> scan(final String tableName, final Map scanFilter) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Stream> call() throws Exception {
return dbExecutor.scan(tableName, scanFilter);
}
});
}
public ContinuableFuture>> scan(final String tableName, final List attributesToGet,
final Map scanFilter) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Stream> call() throws Exception {
return dbExecutor.scan(tableName, attributesToGet, scanFilter);
}
});
}
public ContinuableFuture>> scan(final ScanRequest scanRequest) {
return asyncExecutor.execute(new Callable>>() {
@Override
public Stream> call() throws Exception {
return dbExecutor.scan(scanRequest);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final List attributesToGet) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return dbExecutor.scan(targetClass, tableName, attributesToGet);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final Map scanFilter) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return dbExecutor.scan(targetClass, tableName, scanFilter);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final List attributesToGet,
final Map scanFilter) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return dbExecutor.scan(targetClass, tableName, attributesToGet, scanFilter);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final ScanRequest scanRequest) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return dbExecutor.scan(targetClass, scanRequest);
}
});
}
}