1
我遇到了dynamodb問題。我試圖驗證其中包含的數據, 但掃描似乎只返回數據的一個子集,這裏是我使用的是蟒蛇博託綁定來自dynamodb表格描述和掃描計數的值不正確
#!/usr/bin/python
#Check the scanned length of a table against the Table Description
import boto.dynamodb
#Connect
TABLENAME = "MyTableName"
sdbconn = boto.dynamodb.connect_to_region(
"eu-west-1",
aws_access_key_id='-snipped-',
aws_secret_access_key='-snipped-')
#Initial Scan
results = sdbconn.layer1.scan(TABLENAME,count=True)
previouskey = results['LastEvaluatedKey']
#Create Counting Variable
count = results['Count']
#DynamoDB scan results are limited to 1MB but return a Key value to carry on for the next MB
#so loop untill it does not return a continuation point
while previouskey != False:
results = sdbconn.layer1.scan(TABLENAME,exclusive_start_key=previouskey,count=True)
print(count)
count = count + results['Count']
try:
#get next key
previouskey = results['LastEvaluatedKey']
except:
#no key returned so thats all folks!
print(previouskey)
print("Reached End")
previouskey = False
#these presumably should match, they dont on the MyTableName Table, not even close
print(sdbconn.describe_table(TABLENAME)['Table']['ItemCount'])
print(count)
print(sdbconn.describe_table)
代碼給我1748175和 print(count)
給我583021. 我以爲這些應該總是匹配的印象? (我知道6小時更新)在過去的24小時內只增加了300行,儘管 有人知道這是否與dynamodb有關?或者我的代碼有錯誤的假設?
在那裏更多比一個打印(計數)打印?也許你寫的代碼並不像預期的那樣處理LastEvaluatedKey,也許你正在達到配置吞吐量。 –
供應是我的第一個想法,所以我嘗試了10倍增加的容量並得到了相同的結果,LastEvaluatedKey的工作原理如期望從發電機的最終掃描,根本沒有lastevaluatedkey,打印整個結果證實了這一點,這是一個非常古老的dynamov1表,所以即時通訊不知道是否過去一直是一個問題與發電機 – user2903946