// Rows attempts to retrieve an []*AddressRow for the given address. The BlockID
// for the block at which the cached data is valid is also returned. In the
// event of a cache miss, the slice and the *BlockID will be nil.
430736
func (ac *AddressCache) Rows(addr string) ([]dbtypes.AddressRowCompact, *BlockID) {
	aci := ac.addressCacheItem(addr)
	if aci == nil {
		ac.cacheMetrics.RowMiss()
		return nil, nil
	}
	ac.cacheMetrics.RowHit()
	return aci.Rows()
}
1191139
func (e *Encoder) GetRow(v interface{}) ([]string, error) {
	if reflect.TypeOf(v).Kind() != reflect.Struct {
		return nil, StructRequiredError{reflect.TypeOf(v).Kind()}
	}
	// 2nd parm is only used for recursive calls.
	cols, _ := e.marshalStruct(v, false)
	return cols, nil
}
1242656
func (d *Dataset) Rows(index ...int) ([]map[string]interface{}, error) {
	for _, i := range index {
		if i < 0 || i >= d.rows {
			return nil, ErrInvalidRowIndex
		}
	}

	rows := make([]map[string]interface{}, 0, len(index))
	for _, i := range index {
		row, _ := d.Row(i)
		rows = append(rows, row)
	}

	return rows, nil
}
1266664
func (o *querySet) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error) {
	panic(ErrNotImplement)
}
590029
func (ql *QueryList) GetQueryzRows() []QueryDetailzRow {
	ql.mu.Lock()
	rows := []QueryDetailzRow{}
	for _, qd := range ql.queryDetails {
		row := QueryDetailzRow{
			Query:       qd.conn.Current(),
			ContextHTML: callinfo.HTMLFromContext(qd.ctx),
			Start:       qd.start,
			Duration:    time.Since(qd.start),
			ConnID:      qd.connID,
		}
		rows = append(rows, row)
	}
	ql.mu.Unlock()
	sort.Sort(byStartTime(rows))
	return rows
}
1235570
func (m *matrix3x3) row(row int) Point {
	return Point{r3.Vector{m[row][0], m[row][1], m[row][2]}}
}
776578
func (rows *Rows) Values() ([]interface{}, error) {
	if rows.closed {
		return nil, errors.New("rows is closed")
	}

	values := make([]interface{}, 0, len(rows.fields))

	for range rows.fields {
		buf, fd, _ := rows.nextColumn()

		if buf == nil {
			values = append(values, nil)
			continue
		}

		if dt, ok := rows.conn.ConnInfo.DataTypeForOID(fd.DataType); ok {
			value := reflect.New(reflect.ValueOf(dt.Value).Elem().Type()).Interface().(pgtype.Value)

			switch fd.FormatCode {
			case TextFormatCode:
				decoder := value.(pgtype.TextDecoder)
				if decoder == nil {
					decoder = &pgtype.GenericText{}
				}
				err := decoder.DecodeText(rows.conn.ConnInfo, buf)
				if err != nil {
					rows.fatal(err)
				}
				values = append(values, decoder.(pgtype.Value).Get())
			case BinaryFormatCode:
				decoder := value.(pgtype.BinaryDecoder)
				if decoder == nil {
					decoder = &pgtype.GenericBinary{}
				}
				err := decoder.DecodeBinary(rows.conn.ConnInfo, buf)
				if err != nil {
					rows.fatal(err)
				}
				values = append(values, value.Get())
			default:
				rows.fatal(errors.New("Unknown format code"))
			}
		} else {
			rows.fatal(errors.New("Unknown type"))
		}

		if rows.Err() != nil {
			return nil, rows.Err()
		}
	}

	return values, rows.Err()
}
192672
func (m Mat2) Row(row int) Vec2 {
	return Vec2{m[row+0], m[row+2]}
}
578785
func copyRows(rows []map[string]dosa.FieldValue) []map[string]dosa.FieldValue {
	copied := make([]map[string]dosa.FieldValue, len(rows))
	for i, row := range rows {
		copied[i] = copyRow(row)
	}
	return copied
}
84848
func (pgb *ChainDB) updateAddressRows(address string) (rows []*dbtypes.AddressRow, cacheUpdated bool, err error) {
	busy, wait, done := pgb.CacheLocks.rows.TryLock(address)
	if busy {
		// Just wait until the updater is finished.
		<-wait
		err = fmt.Errorf("retry")
		return
	}

	// We will run the DB query, so block others from doing the same. When query
	// and/or cache update is completed, broadcast to any waiters that the coast
	// is clear.
	defer done()

	hash, height := pgb.BestBlock()
	blockID := cache.NewBlockID(hash, height)

	// Retrieve all non-merged address transaction rows.
	rows, err = pgb.AddressTransactionsAll(address)
	if err != nil && err != sql.ErrNoRows {
		return
	}

	// Update address rows cache.
	cacheUpdated = pgb.AddressCache.StoreRows(address, rows, blockID)
	return
}
1018137
func (m Mat4x3) Row(row int) Vec3 {
	return Vec3{m[row+0], m[row+4], m[row+8]}
}
363008
func CopyRow(dr []Datum) []Datum {
	c := make([]Datum, len(dr))
	for i, d := range dr {
		c[i] = *d.Copy()
	}
	return c
}
395441
func (t *Table) Row(i int) (Row, bool) {
	t.mu.RLock()
	defer t.mu.RUnlock()
	if i < 0 || i >= len(t.Data) {
		return nil, false
	}
	return t.Data[i], true
}
477986
func (b *Batch) QueryRowResults() *Row {
	rows, _ := b.QueryResults()
	return (*Row)(rows)

}
1190028
func CompactRows(rows []*AddressRow) []AddressRowCompact {
	compact := make([]AddressRowCompact, 0, len(rows))
	for _, r := range rows {
		hash, err := chainhash.NewHashFromStr(r.TxHash)
		if err != nil {
			fmt.Println("Bad hash", r.TxHash)
			return nil
		}
		mhash, _ := chainhash.NewHashFromStr(r.MatchingTxHash) // zero array on error
		compact = append(compact, AddressRowCompact{
			Address:        r.Address,
			TxBlockTime:    r.TxBlockTime.UNIX(),
			MatchingTxHash: *mhash,
			TxHash:         *hash,
			TxVinVoutIndex: r.TxVinVoutIndex,
			TxType:         r.TxType,
			ValidMainChain: r.ValidMainChain,
			IsFunding:      r.IsFunding,
			Value:          r.Value,
		})
	}
	return compact
}
446556
func (tx *Tx) QueryRowEx(ctx context.Context, sql string, options *QueryExOptions, args ...interface{}) *Row {
	rows, _ := tx.QueryEx(ctx, sql, options, args...)
	return (*Row)(rows)
}
310459
func InsertAddressRows(db *sql.DB, dbAs []*dbtypes.AddressRow, dupCheck, updateExistingRecords bool) ([]uint64, error) {
	// Begin a new transaction.
	dbtx, err := db.Begin()
	if err != nil {
		return nil, fmt.Errorf("unable to begin database transaction: %v", err)
	}

	ids, err := InsertAddressRowsDbTx(dbtx, dbAs, dupCheck, updateExistingRecords)
	if err != nil {
		_ = dbtx.Rollback() // try, but we want the Prepare error back
		return nil, err
	}

	return ids, dbtx.Commit()
}