in dax/internal/client/response.go [813:872]
func decodeTransactGetItemsOutput(ctx context.Context, reader *cbor.Reader, input *dynamodb.TransactGetItemsInput, keySchemaCache *lru.Lru, attrListIdToNames *lru.Lru, output *dynamodb.TransactGetItemsOutput) (*dynamodb.TransactGetItemsOutput, error) {
length, err := reader.ReadArrayLength()
if err != nil {
return output, err
}
if length != 2 {
return output, &smithy.SerializationError{Err: fmt.Errorf("TransactGetResponse needs to have 2 elements, instead had: %d", length)}
}
if output == nil {
output = &dynamodb.TransactGetItemsOutput{}
}
numR, err := reader.ReadArrayLength()
if err != nil {
return output, err
}
if numR != len(input.TransactItems) {
return output, &smithy.SerializationError{Err: fmt.Errorf("TransactGetResponse need to have the same number of Responses "+
"as the length of TransactItems in the input: %d, instead had: %d", len(input.TransactItems), numR)}
}
responses := make([]types.ItemResponse, numR)
for i := 0; i < numR; i++ {
get := input.TransactItems[i].Get
projectionOrdinals, err := buildProjectionOrdinals(get.ProjectionExpression, get.ExpressionAttributeNames)
if err != nil {
return output, err
}
item, err := decodeNonKeyAttributes(ctx, reader, attrListIdToNames, projectionOrdinals)
if err != nil {
return output, err
}
// The key attributes are only added if it's NOT a projection
if item != nil && len(projectionOrdinals) == 0 {
for k, v := range get.Key {
item[k] = v
}
}
responses[i] = types.ItemResponse{Item: item}
}
output.Responses = responses
numCC, err := reader.ReadArrayLength()
if err != nil {
return output, err
}
if numCC > 0 {
output.ConsumedCapacity = make([]types.ConsumedCapacity, numCC)
for i := 0; i < numCC; i++ {
capacity, err := decodeConsumedCapacityExtended(reader)
if err != nil {
return output, err
}
output.ConsumedCapacity[i] = *capacity
}
}
return output, nil
}