简体   繁体   English

何时将QueryRequest与Java SDK for AWS一起使用?

[英]When to use QueryRequest with java SDK for AWS?

We have a framework built up around QueryRequest. 我们围绕QueryRequest建立了一个框架。 But our framework was built 12-18 months ago. 但是我们的框架是在12-18个月前构建的。 And as I read current docs like the Developer Guide, I see no reference to QueryRequest. 当我阅读《开发人员指南》等当前文档时,我看不到对QueryRequest的引用。 The example in this document ( Querying Tables Using the AWS SDK for Java Document API ) uses QuerySpec, which is completely new to me. 本文档中的示例( 使用适用于Java Document API的AWS开发工具包查询表 )使用QuerySpec,这对我来说是全新的。 Later in that same document there are more examples using Table.query. 在同一文档的后面,有更多使用Table.query的示例。 There is also a reference to using the Object Persistence Model. 还有关于使用对象持久性模型的参考。

Is QueryRequest outdated, or planned to be deprecated? QueryRequest是过时的还是计划过时的? Is Table.query currently the recommended method to use when you have hash keys, rangeKeyConditions, FilterExpressions, etc.? 当您具有哈希键,rangeKeyConditions,FilterExpressions等时,当前是否建议使用Table.query?

FYI for context, we are currently building up our queryRequest with setSelect(), setTableName(), setKeyConditions(), setQueryFilter(), etc. But a new use case looks like it will need more complex combinations of AND and OR conditions, so it looks like we need to start using FilterExpressions. 仅供参考,在当前情况下,我们目前正在使用setSelect(),setTableName(),setKeyConditions(),setQueryFilter()等构建queryRequest。但是,新的用例似乎需要AND和OR条件的更复杂组合,因此看来我们需要开始使用FilterExpressions。

com.amazonaws.services.dynamodbv2.model.QueryRequest is not deprecated, and it doesn't look like it is targeted to be. com.amazonaws.services.dynamodbv2.model.QueryRequest没有被弃用,而且看起来也不像它的目标那样。 The com.amazonaws.services.dynamodb.model.QueryRequest (notice no v2) was deprecated and, I believe, removed in the 1.9 AWS Java SDK release. com.amazonaws.services.dynamodb.model.QueryRequest (第2版通知)已弃用,并且我认为在1.9 AWS Java SDK版本中已将其删除。

DynamoDB released another library building on top of the low-level Java client called the Document API . DynamoDB在底层Java客户端的基础上发布了另一种称为Document API的库 AWS Developer Blog published a blog explaining its usage ( Part 1 and Part 2 ) and also mentions the reasons behind it, but it essentially makes code both easier to write and easier to read. AWS Developer Blog发布了一个博客,解释了其用法( 第1部分第2部分 ),并提到了其背后的原因,但是从本质上讲,它使代码更易于编写和阅读。 Quoting from Part 1 : 引用第1部分

As you see, the new Document API allows the direct use of plain old Java data types and has less boilerplate. 如您所见,新的Document API允许直接使用普通的旧Java数据类型,并且具有更少的样板。 In fact, the Dynamo Document API can be used to entirely subsume what you can do with the low level client (ie AmazonDynamoDBClient) but with a much cleaner programming model and less code. 实际上,Dynamo Document API可用于完全包含您可以使用低级客户端(即AmazonDynamoDBClient)执行的操作,但具有更简洁的编程模型和更少的代码。

As you can see, saving JSON as a structured document in Amazon DynamoDB , or updating, retrieving and converting the document back into JSON is as easy as 1-2-3. 如您所见,将JSON保存为Amazon DynamoDB中的结构化文档,或将文档更新,检索并将其转换回JSON就像1-2-3一样容易。 :) You can find more examples in the AZ Document API quick-start folder at GitHub. :)您可以在GitHub的AZ Document API快速入门文件夹中找到更多示例。 Happy coding until next time! 祝您下次编码愉快!

It is mostly up to how you want to write your code, but I would say that using the Document API is much easier to read and write than using the low-level Java client. 这主要取决于您要如何编写代码,但是我想说,使用Document API比使用底层Java客户端更容易读写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM