DynamoDB API

The BatchGetItem operation returns the properties of one or more items from one or more tables. You identify the requested item by the primary key.
The BatchWriteItem operation puts or deletes multiple items in one or more tables. A single call to BatchWriteItem can write up to 16 MB of data
                which can contain up to 25 put or delete requests. A single project to be written can be up to 400 KB. Efficiently write or delete large amounts of data. The
CreateTable operation adds a new table to your account and is an asynchronous operation. Once a CreateTable request is received,
             DynamoDB immediately returns CREATING with the response TableStatus. After the table is created, DynamoDB sets the TableStatus to ACTIVE.
    You can only perform read and write operations on the ACTIVE table
DeleteItem delete a single item in the table by the primary key. You can perform a conditional delete operation that deletes the item if it exists, or if it has the expected property value
In addition to deleting an item, you can also use the parameter ReturnValues ​​to return the item's property values ​​in the same operation.
DeleteItem is an idempotent operation unless you specify a condition; running it multiple times on the same item or property will not result in an error response.
Conditional delete can be used to delete items only if certain conditions are met. If these conditions are met, DynamoDB will perform the delete operation. Otherwise, the item will not be deleted.
The DeleteTable operation will delete a table and all its items; after a DeleteTable request, the specified table is in the DELETING state until DynamoDB completes the deletion.
If the table is in the ACTIVE state, it can be dropped.
DynamoDB returns a ResourceInUseException if a table is in the CREATING or UPDATING state
If the specified table does not exist, DynamoDB returns a ResourceNotFoundException. If the table is already in the DELETING state, no error will be returned
When you drop a table, any indexes on that table will also be dropped.
DescribeLimits returns the current configured capacity limits for your AWS account in your region, either for the entire region or any one DynamoDB table you create here
AccountMaxWriteCapacityUnits The maximum total write capacity units your account allows you to configure across all tables in the region
TableMaxWriteCapacityUnits Your account allows you to provide maximum write capacity units for new tables created in this region, including write capacity units for their Global Secondary Index (GSI).
TableMaxWriteCapacityUnits Your account allows you to provide maximum write capacity units for new tables created in this region, including write capacity units for their Global Secondary Index (GSI).
DescribeTimeToLive gives a description of the time-to-live (TTL) state on the specified table.
The GetItem operation returns a set of properties for an item with a given primary key.
    If there is no match, GetItem returns no data and there will be no element in the Item response.
ListTables returns an array of table names associated with the current account and endpoint. ListTables is output in pagination, returning up to 100 table names per page.
ListTagsOfResource lists all tags on an Amazon DynamoDB resource. Each account can call ListTagsOfResource up to 10 times per second.
PutItem creates a new item, or replaces an old item with a new item.
If an item with the same primary key already exists in the specified table, the new item will completely replace the existing item. You can perform conditional permutation operations
(Adds a new item if the store with the specified primary key does not exist), or replaces an existing item if it has some property value.
Query operations use the primary key of a table or a secondary index that directly accesses an item from that table or index.
Use the KeyConditionExpression parameter to provide a specific value for the partition key. \
The Query operation will use the partition key value to return all items from the table or index. The
Scan operation returns one or more items and item properties by accessing each item in a table or a secondary index.
To have DynamoDB return fewer items, you can provide a FilterExpression operation.
TagResource associates a set of tags with an Amazon DynamoDB resource. You can then activate these user-defined tags,
so that they appear on the billing and cost management console for cost allocation tracking. Each account can call TagResource up to 5 times per second.
UntagResource removes a tag's association from an Amazon DynamoDB resource. Each account can call UntagResource up to 5 times per second.
updateItem edits the properties of an existing item, or adds a new item to the table if it doesn't exist. You can place, delete or add property values
You can also perform conditional updates on existing items (insert new attribute name-value pairs if they don't exist),
or replace existing name-value pairs if there are some expected property values).
UpdateTable modifies a given table's configured throughput settings, global secondary indexes, or DynamoDB Streams settings.
You can only do one of the following at a time:


Modify the configuration throughput settings for the table.
Enable or disable streaming on the table.
Drop the global secondary index from the table.
Create a new global secondary index on the table. After the index starts backfilling, you can use UpdateTable for other operations.
UpdateTimeToLive specifies the lifetime of a single table item.
The database automatically deletes the item when it expires. The UpdateTimeToLive method will enable or disable TTL for the specified table.
A successful UpdateTimeToLive call returns the current value of TimeToLiveSpecification; 
DescribeStream    returns information about the stream, including the stream's current state, its Amazon Resource Name (ARN), the composition of its shards, and its corresponding DynamoDB table.
You can call DescribeStream at a maximum rate of 10 per second.
GetRecords retrieves stream records from the given shard. Use the parameter to specify the shard iterator ShardIterator. the shard iterator to specify from which to start
The position in the shard where the stream records are read sequentially. GetRecords returns an empty list if no stream records are available in the shard section pointed to by the iterator.
Note that multiple calls may be required to access a portion of a shard containing stream records.
GetShardIterator returns a shard iterator. Shard iterators provide information on how to retrieve stream records from a shard.
Reading stream records from a shard using the shard iterator on subsequent GetRecords requests
ListStreams returns an array of stream ARNs associated with the current account and endpoint. If the TableName parameter exists,
Then ListStreams will just return the stream ARN for that table.












AttributeDefinition represents attributes used to describe the key schema of tables and indexes.
AttributeValueUpdate represents the attribute to be modified, the operation performed for each, and the new value for each.
Capacity represents the throughput capacity consumed on the table or index.


dynamodb all data types:


S – String
N – Number
B – Binary
BOOL – Boolean
NULL – Null
M – Map
L – List
SS – String set
NN – Number set
BB – Binary set






Exception :
 System.err.println(" Could not complete operation");
    System.err.println("Error Message: " + ase.getMessage());
    System.err.println("HTTP Status: " + ase.getStatusCode());
    System.err.println ("AWS Error Code: " + ase.getErrorCode());
    System.err.println("Error Type:     " + ase.getErrorType());
    System.err.println("Request ID:     " + ase.getRequestId());


DynamoDB 的Java 注释
1. @DynamoDBAttribute(attributeName = "Authors")
public List<String> getBookAuthors() { return BookAuthors; }
Map properties to table properties. By default, each class property maps to an item property with the same name.
DynamoDBMapper uses Authors as attribute names when saving objects to the table
2. @DynamoDBTable(tableName="AutoGeneratedKeysExample")
public class AutoGeneratedKeys {private int id; }

3. @DynamoDBHashKey(attributeName = "Id")
    @DynamoDBAutoGeneratedKey 
Mark the partition key or sort key property as auto-generated. When saving these properties,
DynamoDBMapper will generate a random UUID.
Only string properties can be marked as auto-generated keys.




4. @DynamoDBDocument
    public static class Pictures {private String id;}
Representation classes can be serialized into DynamoDB documents.
For example, suppose you want to map a JSON document to a DynamoDB property of type Map (M).
Use the following code snippet to define an item that contains nested properties (Pictures) of type Map.
5. @DynamoDBHashKey(attributeName="Id")
Map class attributes to the table's partition key. Properties must be of type scalar string, number, or binary, not a collection type.


6. @DynamoDBIgnore
Instructs the DynamoDBMapper instance to ignore the associated property. When saving data to the table,
DynamoDBMapper does not save this property to the table.




7. @DynamoDBIndexHashKey


@DynamoDBIndexHashKey(globalSecondaryIndexName = "PostedBy-Message-Index", attributeName = "PostedBy")
Maps class attributes to the partition key of the global secondary index. Attribute must be a scalar string,
A numeric or binary type, not a collection type.

Use this annotation if you need to perform a Query operation on a global secondary index.
The index name (globalSecondaryIndexName) must be specified.
If the name of the class property is different from the index partition key,
then you must also specify the name of the indexed attribute (attributeName).


8. @DynamoDBIndexRangeKey


@DynamoDBIndexRangeKey(globalSecondaryIndexName = "PostedBy-Message-Index", attributeName = "Message"
Sort keys that map class attributes to global secondary indexes or local secondary indexes
. Properties must be of type scalar string, number, or binary, not a collection type.




If you need to perform a Query operation on a local secondary index or a global secondary index,
and want to refine the results using the index sort key, use this annotation. index name must be specified
(globalSecondaryIndexName 或 localSecondaryIndexName)。
If the name of the class property is different from the index sort key, you must also specify the name of the index property
(attributeName)。


9. @DynamoDBRangeKey
Map class attributes to the table's sort keys. Properties must be of type scalar string, number, or binary, not a collection type.



10. @DynamoDBTable


@DynamoDBTable(tableName="People") 
public class Developer { ...} 
Determine the target table in DynamoDB. For example, the following Java snippet defines the Developer class,
and map it to the People table in DynamoDB.


11. @DynamoDBTypeConverted


Annotation for marking properties to use custom type converters.
Can be annotated on user-defined annotations to pass more properties to DynamoDBTypeConverter.
12. @DynamoDBTyped

Annotation for overriding standard property type bindings. If the default property binding for standard types is applied,
the annotation is not required for that type.


13. @DynamoDBVersionAttribute

Determines a class property to store the optimistic locking version number. DynamoDBMapper 
A version number is assigned to this property when a new project is saved,
and will increment the value of the version number each time you update the project. Only numeric scalar types are supported






DynamoDBMapper class method
1. save
mapper.save(obj, new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.CLOBBER));
Save the specified object to the table. The object you want to save is the only required parameter for this method.
You can provide optional configuration parameters using the DynamoDBMapperConfig object.






2.load
CatalogItem item = mapper.load(CatalogItem.class, item.getId(), 
                new DynamoDBMapperConfig(DynamoDBMapperConfig.ConsistentReads.CONSISTENT)); 


Retrieve items in the table. You must provide the primary key of the item to retrieve.
You can provide optional configuration parameters using the DynamoDBMapperConfig object.
For example, you can choose to request a strongly consistent read to ensure this method retrieves only the latest item value
(as shown in the following Java statement).


3. delete


Delete an item from the table. You must pass in an object instance of the mapped class. 4. query Reply ( Id, ReplyDateTime, ...


)



Lookup table or secondary index. Only if the table or index has a composite primary key (partition key and sort key),
You can perform queries on it. This method requires you to provide a partition key value and a query filter to apply to the sort key
. A filter expression consists of a condition and a value.




5. queryPage


Query a table or secondary index and return a single page of matching results. As with the query method,
You must specify a partition key value and a query filter to apply to the sort key property. However,
queryPage returns only the first "page" of data, which is a size that fits into 1 MB.


6. scan
List<Reply> replies = mapper.scan(Reply.class, scanExpression);


Scan the entire table or secondary index. You can optionally specify a FilterExpression to filter the result set.


7. scanPage


Scans a table or secondary index and returns a single page of matching results. As with the scan method,
You can optionally specify a FilterExpression to filter the result set. However,
scanPage returns only the first "page" of data, which is an amount of data that fits in 1 MB.


8.parallelScan


List<Product> scanResult = mapper.parallelScan(Product.class, scanExpression, numberOfThreads)
Perform a parallel scan of the entire table or secondary index. You can specify several logical segments of the table,
And specify the scan expression used to filter the results. parallelScan breaks down the scan task into
Multiple worker threads, one for each logical segment; the number of worker threads processed in parallel
and return the result.


9.batchSave


mapper.batchSave(Arrays.asList(book1, book2));


call the AmazonDynamoDB.batchWriteItem method one or more times,
to store objects in one or more tables. This method does not provide transaction guarantees.


10. batchLoad


Map<String, List<Object>> items = mapper.batchLoad(itemsToGet);


Retrieves multiple items from one or more tables using the primary key.


11.batchDelete


mapper.batchDelete(Arrays.asList(book1, book2));


call the AmazonDynamoDB.batchWriteItem method one or more times,
to delete items from one or more tables. This method does not provide transaction guarantees.




12.batchWrite


mapper.batchWrite(objectsToWrite, objectsToDelete);


call the AmazonDynamoDB.batchWriteItem method one or more times,
To save objects in one or more tables and delete. This method does not provide transaction guarantees,
Versioning (conditional put or delete) is also not supported.


13.count


Evaluates the specified scan expression and returns the number of matching items. No item data is returned.


14. generateCreateTableRequest


Parses the POJO class representing the DynamoDB table and returns a CreateTableRequest for that table.


15. createS3Link


public S3Link productImage;


Create links to objects in Amazon S3. The bucket name must be specified and used for unique
The key name that identifies the object in the bucket




16.getS3ClientCache






Returns the underlying S3ClientCache used to access Amazon S3.
An S3ClientCache is a smart map for AmazonS3Client objects.
If you have multiple clients, S3ClientCache can help you organize clients by region,
And new Amazon S3 clients can be created on demand.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326001999&siteId=291194637