Esempio n. 1
0
func (qe *QueryEngine) fetchIterate(logStats *sqlQueryStats, conn PoolConnection,
	start, end []byte, limit int, ignoreKey, ignoreValue bool) (keys [][]byte, values [][]byte) {
	var err error
	if conn == nil {
		waitingForConnectionStart := time.Now()
		conn, err = qe.connPool.SafeGet()
		logStats.WaitingForConnection += time.Now().Sub(waitingForConnectionStart)
		if err != nil {
			panic(NewTabletErrorDB(FATAL, err))
		} else {
			defer conn.Recycle()
		}
	}
	var cursor eproto.DbCursor
	if cursor, err = conn.Iterate(nil, start, end, limit); err != nil {
		panic(NewTabletErrorDB(FAIL, err))
	}
	for ; cursor.Valid(); cursor.Next() {
		if !ignoreKey {
			keys = append(keys, cursor.Key())
		}
		if !ignoreValue {
			values = append(values, cursor.Value())
		}
	}
	if cursor.Error() != nil {
		panic(NewTabletErrorDB(FAIL, err))
	}
	return keys, values
}