Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在DynamoDB上设置独占启动密钥_Java_Amazon Web Services_Amazon Dynamodb_Aws Sdk - Fatal编程技术网

Java 无法在DynamoDB上设置独占启动密钥

Java 无法在DynamoDB上设置独占启动密钥,java,amazon-web-services,amazon-dynamodb,aws-sdk,Java,Amazon Web Services,Amazon Dynamodb,Aws Sdk,我正在尝试将独占开始密钥设置为我的请求,以便以后可以使用我的最后一个EvaluatedKey 当我迭代查询结果时,会发生以下异常。在这方面有人能帮我吗 “提供的起始键与范围键谓词不匹配” 如果您正在传递的ExclusiveStartKey表示的行不再出现在dynamodb查询结果中,则可能会发生这种情况 考虑以下情况: Your Primary partition key is named "message_id" Your Primary sort key is named "message

我正在尝试将独占开始密钥设置为我的请求,以便以后可以使用我的最后一个EvaluatedKey

当我迭代查询结果时,会发生以下异常。在这方面有人能帮我吗

“提供的起始键与范围键谓词不匹配”


如果您正在传递的ExclusiveStartKey表示的行不再出现在dynamodb查询结果中,则可能会发生这种情况

考虑以下情况:

Your Primary partition key is named "message_id" Your Primary sort key is named "message_timestamp" Your ExclusiveStartKey value is: '{"message_id":"3483b80a358cf60decfccc329bd5e72e","message_timestamp":1481114525}' You are using KeyConditionExpression as: Key("message_id").eq("3483b80a358cf60decfccc329bd5e72e") & Key("message_timestamp").gt(1481202107) Since the message_timestamp in KeyConditionExpression is greater than the corresponding value in ExclusiveStartKey, dynamodb will throw the error that you mentioned. 您的主分区密钥名为“message\u id” 您的主排序键名为“message\u timestamp” 您的ExclusiveStartKey值为:“{”message_id:“3483B80A358CF60DECFCC329BD5E72E”,“message_timestamp:“1481114525}” 您使用的KeyConditionExpression为:Key(“message_id”).eq(“3483b80a358cf60decfcc329bd5e72e”)和Key(“message_timestamp”).gt(1481202107) 由于KeyConditionExpression中的消息_时间戳大于ExclusiveStartKey中的相应值,dynamodb将抛出您提到的错误。
“提供的起始键与范围键谓词不匹配”意味着DynamoDB无法命中由您的查询条件表示的ExclusiveStateKey项。因此,当您使用queryPage api时,最好在找到最后一项之前不要更改查询条件;最好不要更新分页结果中可能包含的项目


希望这个答案能对其他人有所帮助。

我的理解是,如果表中不再包含独占开始键提供的值,则这不是错误。
com.amazonaws.AmazonServiceException: The provided starting key does not match the range key predicate (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: 6EA9NOO079F7VUVV1JP92P05MRVV4KQNSO5AEMVJF66Q9ASUAAJG)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1389)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:902)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
    at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
    at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
    at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:1985)
    at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.query(AmazonDynamoDBClient.java:1620)
    at com.amazonaws.services.dynamodbv2.document.internal.QueryCollection.firstPage(QueryCollection.java:53)
    at com.amazonaws.services.dynamodbv2.document.internal.PageIterator.next(PageIterator.java:45)
    at com.amazonaws.services.dynamodbv2.document.internal.PageIterator.next(PageIterator.java:25)
    at java.lang.Iterable.forEach(Iterable.java:74)
    at com.my.com.services.database.DynamoDatabaseRepository.fetchMessageList(DynamoDatabaseRepository.java:675)
    at service.DatabaseServiceTest.accc(DatabaseServiceTest.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)
Your Primary partition key is named "message_id" Your Primary sort key is named "message_timestamp" Your ExclusiveStartKey value is: '{"message_id":"3483b80a358cf60decfccc329bd5e72e","message_timestamp":1481114525}' You are using KeyConditionExpression as: Key("message_id").eq("3483b80a358cf60decfccc329bd5e72e") & Key("message_timestamp").gt(1481202107) Since the message_timestamp in KeyConditionExpression is greater than the corresponding value in ExclusiveStartKey, dynamodb will throw the error that you mentioned.