Reputation: 159
I'm using eclipse to put and get items in simpleDB through java. I inserted about 1000 items. Then, I made a query to get the number of items in the domain, but it returned 100.
I also use aws explorer in eclipse to know the number of items inserted and I found 100 items only. If I tried to insert more items, I don't get any error message but they were not inserted. I don't think that there is a fixed limit (100 items) in one domain.
Can anyone help me to know what is the reason? How I can insert more than 100 items?
Upvotes: 1
Views: 202
Reputation: 51
As Peter Pei Guo already explained you have to look for Next token in the response. Here is sample code I am using for querying SimpleDB Domains.
public List<Item> getItems(){
AmazonSimpleDBClient client = new AmazonSimpleDBClient(...);
List<Item> items = new ArrayList<>();
String nextToken = null;
do {
final SelectRequest request = new SelectRequest();
request.setSelectExpression("MY SELECT QUERY");
// SimpleDB can paginate the result. For paginated result NextToken value will be not null
request.setNextToken(nextToken);
nextToken = null;
SelectResult result = client.select(request);
if (result != null) {
nextToken = (result.getNextToken() != null) ? result.getNextToken() : null;
items.addAll(result.getItems());
}
} while (nextToken != null);
return items;
}
Upvotes: 1
Reputation: 7870
The problem is the select not the insert.
Simple db query is purposely designed that way, and it only returns partial select result when the result becomes too large or taking too long to transmit.
Check your SelectResult, call getNextToken on it, if it is not null, you have more left to select. To continue, you do another select, this time with the token from last time.
You need to loop until the next token becomes null.
Upvotes: 2