Migration details for DynamoDB v2 in AWS Java SDK?

前端 未结 2 1055
猫巷女王i
猫巷女王i 2021-02-01 23:55

Has anyone made the change to the new namespaces (com.amazonaws.services.dynamodbv2) and interfaces for DynamoDB in the AWS Java SDK 1.4.2 (and later)? The release

2条回答
  •  自闭症患者
    2021-02-02 00:28

    The new dynamodbv2 namespace of DynamoDB introduces the following incompatible changes (in that they are not simply additive, and require code changes to switch to the new namespace):

    • HashKeyElement and RangeKeyElement are replaced with a Map. This includes the structures named ExclusiveStartKey, LastEvaluatedKey, and Key. The main impact on the code with this change is that now in order to call GetItem, for example, your code needs to know the attribute names of the primary keys, and not just the primary key values.
    • Query now uses a KeyCondition of type Map to specify the full query, instead of having separate HashKeyValue and RangeKeyCondition fields.
    • CreateTable input separates the attribute type definitions from the primary key definitions (and create/update/delete/describe responses match this)
    • Consumed Capacity in responses is now a structure instead of a single number, and must be asked for in the request. In Batch operations, this is returned in a separate ConsumedCapacity structure, instead of alongside the results.

    It is possible to migrate your code to the new Java API incrementally, if desired. If you plan to add functionality to your code that queries Local Secondary Indexes, or creates tables with local secondary indexes, you will need to use the new API for that part of your code.

    If you create a table with Local Secondary Indexes with the new API, you can still use your existing code in the dynamodb namespace to perform all of the existing operations on that table. As an example, PutItem with the dynamodb namespace client will work against tables created using the dynamodbv2 client, as well as the other way around.

提交回复
热议问题