<small id='U8094'></small><noframes id='U8094'>

    <bdo id='U8094'></bdo><ul id='U8094'></ul>
  • <legend id='U8094'><style id='U8094'><dir id='U8094'><q id='U8094'></q></dir></style></legend>

      <i id='U8094'><tr id='U8094'><dt id='U8094'><q id='U8094'><span id='U8094'><b id='U8094'><form id='U8094'><ins id='U8094'></ins><ul id='U8094'></ul><sub id='U8094'></sub></form><legend id='U8094'></legend><bdo id='U8094'><pre id='U8094'><center id='U8094'></center></pre></bdo></b><th id='U8094'></th></span></q></dt></tr></i><div id='U8094'><tfoot id='U8094'></tfoot><dl id='U8094'><fieldset id='U8094'></fieldset></dl></div>
      <tfoot id='U8094'></tfoot>

        如何使用 Java 设置 DynamoDB 返回的匹配项的限制

        时间:2023-09-29

        <legend id='t2qqA'><style id='t2qqA'><dir id='t2qqA'><q id='t2qqA'></q></dir></style></legend>

          <i id='t2qqA'><tr id='t2qqA'><dt id='t2qqA'><q id='t2qqA'><span id='t2qqA'><b id='t2qqA'><form id='t2qqA'><ins id='t2qqA'></ins><ul id='t2qqA'></ul><sub id='t2qqA'></sub></form><legend id='t2qqA'></legend><bdo id='t2qqA'><pre id='t2qqA'><center id='t2qqA'></center></pre></bdo></b><th id='t2qqA'></th></span></q></dt></tr></i><div id='t2qqA'><tfoot id='t2qqA'></tfoot><dl id='t2qqA'><fieldset id='t2qqA'></fieldset></dl></div>
          <tfoot id='t2qqA'></tfoot>
                  <tbody id='t2qqA'></tbody>

                <small id='t2qqA'></small><noframes id='t2qqA'>

                • <bdo id='t2qqA'></bdo><ul id='t2qqA'></ul>
                  本文介绍了如何使用 Java 设置 DynamoDB 返回的匹配项的限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在我的 Android 应用程序中,我想从 DynamoDB 查询数据.会有一千个匹配的项目,但我只想得到前 10 个.我不知道如何设置这个限制.我在文档中找到了这些行:

                  In my Android app, I want to query data from DynamoDB. There will be a thousand matching items, but I just want to get only the first 10 of them. I don't know how to set this limit. I found these lines in documentation:

                  DynamoDB 查询和扫描 API 允许使用 Limit 值来限制结果的大小.

                  The DynamoDB Query and Scan APIs allow a Limit value to restrict the size of the results.

                  在请求中,将 Limit 参数设置为您希望 DynamoDB 在返回结果之前处理的项目数.

                  In a request, set the Limit parameter to the number of items that you want DynamoDB to process before returning results.

                  在响应中,DynamoDB 返回限制值范围内的所有匹配结果.例如,如果您发出限制值为 6 且没有过滤器表达式的 Query 或 Scan 请求,则 DynamoDB 会返回表中与请求中指定的键条件匹配的前六个项目(或仅返回表中的前六个项目).没有过滤器的扫描的情况).如果您还提供 FilterExpression 值,DynamoDB 将返回前六个中也符合过滤器要求的项目(返回的结果数将小于或等于 6).

                  但我找不到设置响应限制的方法.我找到了QueryResult的SetCount方法:

                  But I cannot find the way to set limit for response. I found the method SetCount of QueryResult:

                  QueryResult result2 = dynamodb.query(request);
                      result2.setCount(5);
                  

                  上面说:那么Count就是应用过滤器后返回的项目数

                  但我认为这不是我想要的.因为 DynamoDb 在调用 setCount 之前仍然返回所有匹配项.谁能帮帮我?

                  But I think it is not what I want. Because DynamoDb still returns all the matching items before calling setCount. Can any one help me?

                  推荐答案

                  您需要在发送到 API 的请求中应用限制,而不是在响应中.

                  You need to apply the limit as part of the request that you send to the API, not on the response.

                  我假设您提交给 dynamodb 对象的请求对象是 QuerySpec.您要做的是调用 withMaxResultSize 在针对 API 运行查询之前传入您希望应用的限制.

                  I assume the request object you are submitting to the dynamodb object is a QuerySpec. What you will want to do is is call withMaxResultSize to pass in the limit you want applied before the query is run against the API.

                  但是,正如您在问题中提到的,您需要确保了解 限制:

                  However, as you mentioned in your question you need to make sure you understand the behavior of limit as described in the DynamoDB documentation on Limits:

                  在响应中,DynamoDB 返回限值的范围.例如,如果您发出查询或扫描限制值为 6 且没有过滤器表达式的请求,DynamoDB 返回表中与请求中指定的关键条件(或仅前六项在没有过滤器的扫描的情况下).如果您还提供FilterExpression 值,DynamoDB 将返回第一个 中的项目六个也符合过滤器要求(结果的数量返回将小于或等于 6).

                  In a response, DynamoDB returns all the matching results within the scope of the Limit value. For example, if you issue a Query or a Scan request with a Limit value of 6 and without a filter expression, DynamoDB returns the first six items in the table that match the specified key conditions in the request (or just the first six items in the case of a Scan with no filter). If you also supply a FilterExpression value, DynamoDB will return the items in the first six that also match the filter requirements (the number of results returned will be less than or equal to 6).

                  这意味着,如果您不使用 FilterExpression,您可能会没事.但是,如果您正在过滤结果,您收到的结果可能会少于您的限制,因为从技术上讲,限制不是要返回的结果数,而是 DynamoDB 可能返回的项目数.

                  What this means is that if you are not using a FilterExpression you are likely fine. However, if you are filtering the results you will likely receive fewer than your limit because the limit is technically not the number of results to return rather the number of items DynamoDB could potentially return.

                  听起来您在寻求一种方法,让 DynamoDB 在应用 FilterExpression 的同时将返回的结果数量限制为精确数字.不幸的是,DynamoDB 目前无法做到这一点.

                  It sounds like you are asking for a way to have DynamoDB limit the number of results it returns to an exact number while having a FilterExpression applied. Unfortunately this is currently not possible with DynamoDB.

                  这篇关于如何使用 Java 设置 DynamoDB 返回的匹配项的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:有没有办法在 DynamoDB 中查询多个哈希键? 下一篇:简单的 DynamoDB 请求失败并出现 ResourceNotFoundExce

                  相关文章

                  最新文章

                • <i id='0zBqk'><tr id='0zBqk'><dt id='0zBqk'><q id='0zBqk'><span id='0zBqk'><b id='0zBqk'><form id='0zBqk'><ins id='0zBqk'></ins><ul id='0zBqk'></ul><sub id='0zBqk'></sub></form><legend id='0zBqk'></legend><bdo id='0zBqk'><pre id='0zBqk'><center id='0zBqk'></center></pre></bdo></b><th id='0zBqk'></th></span></q></dt></tr></i><div id='0zBqk'><tfoot id='0zBqk'></tfoot><dl id='0zBqk'><fieldset id='0zBqk'></fieldset></dl></div>

                    <bdo id='0zBqk'></bdo><ul id='0zBqk'></ul>
                  <tfoot id='0zBqk'></tfoot>

                • <small id='0zBqk'></small><noframes id='0zBqk'>

                    <legend id='0zBqk'><style id='0zBqk'><dir id='0zBqk'><q id='0zBqk'></q></dir></style></legend>