func (a *appStats) Add(other *appStats) {
	other.Lock()
	statMap := make(map[stmtKey]*stmtStats)
	for k, v := range other.stmts {
		statMap[k] = v
	}
	other.Unlock()

	// Copy the statement stats for each statement key.
	for k, v := range statMap {
		v.Lock()
		statCopy := &stmtStats{data: v.data}
		v.Unlock()
		statMap[k] = statCopy
	}

	// Merge the statement stats.
	for k, v := range statMap {
		s := a.getStatsForStmtWithKey(k, true)
		s.Lock()
		// Note that we don't need to take a lock on v because
		// no other thread knows about v yet.
		s.data.Add(&v.data)
		s.Unlock()
	}

	// Create a copy of the other's transactions statistics.
	other.txns.mu.Lock()
	txnStats := other.txns.mu.TxnStats
	other.txns.mu.Unlock()

	// Merge the transaction stats.
	a.txns.mu.Lock()
	a.txns.mu.TxnStats.Add(txnStats)
	a.txns.mu.Unlock()
}
// Add combines one appStats into another. Add manages locks on a, so taking
// a lock on a will cause a deadlock.
Add combines one appStats into another. Add manages locks on a, so taking
a lock on a will cause a deadlock.
// Add combines one appStats into another . Add manages locks on a so taking // a lock on a will cause a deadlock .
func (a *appStats) Add(other *appStats) {
	other.Lock()
	statMap := make(map[stmtKey]*stmtStats)
	for k, v := range other.stmts {
		statMap[k] = v
	}
	other.Unlock()
	for k, v := range statMap {
		v.Lock()
		statCopy := &stmtStats{data: v.data}
		v.Unlock()
		statMap[k] = statCopy
	}
	for k, v := range statMap {
		s := a.getStatsForStmtWithKey(k, true)
		s.Lock()
		s.data.Add(&v.data)
		s.Unlock()
	}
	other.txns.mu.Lock()
	txnStats := other.txns.mu.TxnStats
	other.txns.mu.Unlock()
	a.txns.mu.Lock()
	a.txns.mu.TxnStats.Add(txnStats)
	a.txns.mu.Unlock()
}
func ( a * appStats ) Add ( other * appStats ) { other . Lock ( ) statMap := make ( map [ stmtKey ] * stmtStats ) for k , v := range other . stmts { statMap [ k ] = v } other . Unlock ( ) for k , v := range statMap { v . Lock ( ) statCopy := & stmtStats { data : v . data } v . Unlock ( ) statMap [ k ] = statCopy } for k , v := range statMap { s := a . getStatsForStmtWithKey ( k , true ) s . Lock ( ) s . data . Add ( & v . data ) s . Unlock ( ) } other . txns . mu . Lock ( ) txnStats := other . txns . mu . TxnStats other . txns . mu . Unlock ( ) a . txns . mu . Lock ( ) a . txns . mu . TxnStats . Add ( txnStats ) a . txns . mu . Unlock ( ) }
Add combines one appStats into another.
Add combines one appStats into another .
// Copy the statement stats for each statement key. // Merge the statement stats. // Note that we don't need to take a lock on v because // no other thread knows about v yet. // Create a copy of the other's transactions statistics. // Merge the transaction stats.