AWS Java SDK中DynamoDB v2的迁移详细信息? [英] Migration details for DynamoDB v2 in AWS Java SDK?

查看:36
本文介绍了AWS Java SDK中DynamoDB v2的迁移详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人在AWS Java SDK 1.4.2(及更高版本)中更改了新名称空间( com.amazonaws.services.dynamodbv2 )和DynamoDB的接口吗?根据 1.4.2发行说明,本地二级索引的发布显然需要进行重大更改.

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 of Local Secondary Indices apparently necessitated breaking changes as per the 1.4.2 release notes.

有没有人找到详细介绍迁移现有代码需要进行哪些更改以及需要进行哪些操作的指南?我正在尝试确定何时最好对现有代码库进行此更改.

Has anyone found a guide detailing what changed and what needs to happen to migrate existing code? I am trying to decide when is best to make this change for an existing code base.

推荐答案

DynamoDB的新 dynamodbv2 命名空间引入了以下不兼容的更改(因为它们并非简单的累加,并且需要更改代码才能切换到新的名称空间):

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 RangeKeyElement 被替换为 Map< String,AttributeValue> .这包括名为 ExclusiveStartKey LastEvaluatedKey Key 的结构.进行此更改对代码的主要影响是,例如,现在为了调用 GetItem ,您的代码需要知道主键的属性名称,而不仅仅是主键值./li>现在,
  • 查询使用类型为 Map< String,Condition> KeyCondition 来指定完整查询,而不是使用单独的 HashKeyValue RangeKeyCondition 字段.
  • CreateTable输入将属性类型定义与主键定义分开(并且与此相匹配的创建/更新/删除/描述响应)
  • 响应中的已用容量现在是一个结构,而不是单个数字,必须在请求中进行询问.在批处理操作中,这将在单独的 ConsumedCapacity 结构中返回,而不是与结果一起返回.
  • HashKeyElement and RangeKeyElement are replaced with a Map<String, AttributeValue>. 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<String, Condition> 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.

如果需要,可以将代码增量地迁移到新的Java API.如果计划在查询本地二级索引的代码中添加功能,或使用本地二级索引创建表,则需要为该部分代码使用新的API.

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.

如果使用新API使用本地二级索引创建表,您仍可以使用 dynamodb 名称空间中的现有代码在该表上执行所有现有操作.例如,带有 dynamodb 命名空间客户端的PutItem将与使用 dynamodbv2 客户端创建的表一起工作,反之亦然.

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.

这篇关于AWS Java SDK中DynamoDB v2的迁移详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆