Exemple #1
0
// Add ConsumedCapacity from "this" Response to "all", the eventual stitched Response.
func combineResponseMetadata(all, this *Response) error {
	combinedConsumedCapacity := make([]ep.ConsumedCapacity, 0)
	for _, this_cc := range this.ConsumedCapacity {
		var cc ep.ConsumedCapacity
		cc.TableName = this_cc.TableName
		cc.CapacityUnits = this_cc.CapacityUnits
		for _, all_cc := range all.ConsumedCapacity {
			if all_cc.TableName == this_cc.TableName {
				cc.CapacityUnits += all_cc.CapacityUnits
			}
		}
		combinedConsumedCapacity = append(combinedConsumedCapacity, cc)
	}
	all.ConsumedCapacity = combinedConsumedCapacity
	for tn, _ := range this.ItemCollectionMetrics {
		for _, icm := range this.ItemCollectionMetrics[tn] {
			if _, tn_is_all := all.ItemCollectionMetrics[tn]; !tn_is_all {
				all.ItemCollectionMetrics[tn] =
					make([]ep.ItemCollectionMetrics, 0)
			}
			all.ItemCollectionMetrics[tn] = append(all.ItemCollectionMetrics[tn], icm)
		}
	}
	return nil
}
Exemple #2
0
// Add ConsumedCapacity from "this" Response to "all", the eventual stitched Response.
func combineResponseMetadata(all, this *Response) error {
	combinedConsumedCapacity := make([]ep.ConsumedCapacity, 0)
	for _, this_cc := range this.ConsumedCapacity {
		var cc ep.ConsumedCapacity
		cc.TableName = this_cc.TableName
		cc.CapacityUnits = this_cc.CapacityUnits
		for _, all_cc := range all.ConsumedCapacity {
			if all_cc.TableName == this_cc.TableName {
				cc.CapacityUnits += all_cc.CapacityUnits
			}
		}
		combinedConsumedCapacity = append(combinedConsumedCapacity, cc)
	}
	all.ConsumedCapacity = combinedConsumedCapacity
	return nil
}