Added ScannedCount field to DynamoDB query response.
This commit is contained in:
parent
66032ad37c
commit
c2df7732e5
@ -369,7 +369,11 @@ class Table(object):
|
|||||||
if scan_index_forward is False:
|
if scan_index_forward is False:
|
||||||
results.reverse()
|
results.reverse()
|
||||||
|
|
||||||
return self._trim_results(results, limit, exclusive_start_key)
|
scanned_count = len(self.all_items())
|
||||||
|
|
||||||
|
results, last_evaluated_key = self._trim_results(results, limit,
|
||||||
|
exclusive_start_key)
|
||||||
|
return results, scanned_count, last_evaluated_key
|
||||||
|
|
||||||
def all_items(self):
|
def all_items(self):
|
||||||
for hash_set in self.items.values():
|
for hash_set in self.items.values():
|
||||||
|
@ -319,7 +319,7 @@ class DynamoHandler(BaseResponse):
|
|||||||
exclusive_start_key = self.body.get('ExclusiveStartKey')
|
exclusive_start_key = self.body.get('ExclusiveStartKey')
|
||||||
limit = self.body.get("Limit")
|
limit = self.body.get("Limit")
|
||||||
scan_index_forward = self.body.get("ScanIndexForward")
|
scan_index_forward = self.body.get("ScanIndexForward")
|
||||||
items, last_evaluated_key = dynamodb_backend2.query(
|
items, scanned_count, last_evaluated_key = dynamodb_backend2.query(
|
||||||
name, hash_key, range_comparison, range_values, limit,
|
name, hash_key, range_comparison, range_values, limit,
|
||||||
exclusive_start_key, scan_index_forward, index_name=index_name)
|
exclusive_start_key, scan_index_forward, index_name=index_name)
|
||||||
if items is None:
|
if items is None:
|
||||||
@ -329,6 +329,7 @@ class DynamoHandler(BaseResponse):
|
|||||||
result = {
|
result = {
|
||||||
"Count": len(items),
|
"Count": len(items),
|
||||||
"ConsumedCapacityUnits": 1,
|
"ConsumedCapacityUnits": 1,
|
||||||
|
"ScannedCount": scanned_count
|
||||||
}
|
}
|
||||||
if self.body.get('Select', '').upper() != 'COUNT':
|
if self.body.get('Select', '').upper() != 'COUNT':
|
||||||
result["Items"] = [item.attrs for item in items]
|
result["Items"] = [item.attrs for item in items]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user