我试图弄清楚如何使用AWSiOSSDKv2撰写批量读取操作。我似乎无法找到任何文档或示例。
测试我正在尝试针对单个表创建批量读取请求," prod_content_list"。该表只有一个在属性上定义的主哈希键," id"。该表没有任何范围或二级索引。
这是我到目前为止所做的:
public func getContentEntries(){
// define the primary hash key
var hashAttribute = AWSDynamoDBAttributeValue()
hashAttribute.S = "54c2af81a4f36"
// define an equality condition
var hashCondition = AWSDynamoDBCondition()
hashCondition.comparisonOperator = .EQ
hashCondition.attributeValueList = [hashAttribute]
// add attribute to keys map
let keys:Array = [["id":hashCondition]]
// create AWSDynamoDBKeysAndAttributes instance and assign contentListAttributeMap
let contentListAttributeMap = AWSDynamoDBKeysAndAttributes()
contentListAttributeMap.keys = keys
// create a table map; mapping table name to keys map(single table in this example)
let tableMap = ["prod_content_list" : contentListAttributeMap]
var request = AWSDynamoDBBatchGetItemInput()
request.requestItems = tableMap
request.returnConsumedCapacity = AWSDynamoDBReturnConsumedCapacity.Total
var client = AWSDynamoDB(forKey: "USWest2DynamoDB")
var response = client.batchGetItem(request)
if(response.error != nil){
// Check for error
}else if(response.exception != nil){
// Check for exception
}else{
// Get results
let output = response.result
}
}
上述测试方法不报告任何错误或异常,但BFTask.result为零。我知道如果没有找到记录,BFTask结果可能是nil,但我的例子中的哈希码肯定存在。我必须假设我在请求中定义属性/键映射或表/属性映射的方式有问题。有人能告诉我这里哪里出错吗?
由于