// UncompactMergedRows converts (to the extent possible) a []AddressRowMerged to
// a []*AddressRow. VinVoutDbID is unknown and set to zero. Do not use
// VinVoutDbID, or insert the AddressRow.
178687
func UncompactMergedRows(merged []AddressRowMerged) []*AddressRow {
	rows := make([]*AddressRow, 0, len(merged))
	for i := range merged {
		r := &merged[i]
		rows = append(rows, &AddressRow{
			Address:        r.Address,
			ValidMainChain: r.ValidMainChain,
			// no MatchingTxHash for merged
			IsFunding:   r.IsFunding(),
			TxBlockTime: NewTimeDefFromUNIX(r.TxBlockTime),
			TxHash:      r.TxHash.String(),
			// no TxVinVoutIndex for merged
			Value: r.Value(),
			// no VinVoutDbID for merged
			MergedCount: uint64(r.MergedCount),
			TxType:      r.TxType,
		})
	}
	return rows
}
943295
func (cd CompactData) Rows(each func(i int, row Row)) {
	for i, row := range cd.CompactRows {
		each(i, row.Parse(cd.Delimiter))
	}
}
90580
func (f *File) ajustSingleRowDimensions(r *xlsxRow, num int) {
	r.R = num
	for i, col := range r.C {
		colName, _, _ := SplitCellName(col.R)
		r.C[i].R, _ = JoinCellName(colName, num)
	}
}
917046
func MakeCsvAddressRows(rows []*dbtypes.AddressRow) [][]string {
	csvRows := make([][]string, 0, len(rows)+1)
	csvRows = append(csvRows, []string{"tx_hash", "direction", "io_index",
		"valid_mainchain", "value", "time_stamp", "tx_type", "matching_tx_hash"})

	for _, r := range rows {
		var strValidMainchain string
		if r.ValidMainChain {
			strValidMainchain = "1"
		} else {
			strValidMainchain = "0"
		}

		var strDirection string
		if r.IsFunding {
			strDirection = "1"
		} else {
			strDirection = "-1"
		}

		csvRows = append(csvRows, []string{
			r.TxHash,
			strDirection,
			strconv.Itoa(int(r.TxVinVoutIndex)),
			strValidMainchain,
			strconv.FormatFloat(dcrutil.Amount(r.Value).ToCoin(), 'f', -1, 64),
			strconv.FormatInt(r.TxBlockTime.UNIX(), 10),
			txhelpers.TxTypeToString(int(r.TxType)),
			r.MatchingTxHash,
		})
	}
	return csvRows
}
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()
}
883913
func (dt *DbfTable) GetRowAsSlice(row int) []string {

	s := make([]string, len(dt.Fields()))

	for i := 0; i < len(dt.Fields()); i++ {
		s[i] = dt.FieldValue(row, i)
	}

	return s
}
297841
func TruncateToRowKeyLen(key kv.Key) kv.Key {
	if len(key) > recordRowKeyLen {
		return key[:recordRowKeyLen]
	}
	return key
}
746200
func (f *fragment) unprotectedRow(rowID uint64) *Row {
	r, ok := f.rowCache.Fetch(rowID)
	if ok && r != nil {
		return r
	}

	row := f.rowFromStorage(rowID)
	f.rowCache.Add(rowID, row)
	return row
}
991897
func (s String) UnsortedList() []string {
	res := make([]string, 0, len(s))
	for key := range s {
		res = append(res, key)
	}
	return res
}
1033538
func RegisteredAdaptors() []string {
	all := make([]string, 0)
	for i := range adaptors {
		all = append(all, i)
	}
	return all
}
211951
func (t *Table) unsafeAddBindings(bs []string) {
	for _, b := range bs {
		if !t.mbs[b] {
			t.mbs[b] = true
			t.AvailableBindings = append(t.AvailableBindings, b)
		}
	}
}
373647
func (mr MutRow) ShallowCopyPartialRow(colIdx int, row Row) {
	for i, srcCol := range row.c.columns {
		dstCol := mr.c.columns[colIdx+i]
		if !srcCol.isNull(row.idx) {
			// MutRow only contains one row, so we can directly set the whole byte.
			dstCol.nullBitmap[0] = 1
		} else {
			dstCol.nullBitmap[0] = 0
		}

		if srcCol.isFixed() {
			elemLen := len(srcCol.elemBuf)
			offset := row.idx * elemLen
			dstCol.data = srcCol.data[offset : offset+elemLen]
		} else {
			start, end := srcCol.offsets[row.idx], srcCol.offsets[row.idx+1]
			dstCol.data = srcCol.data[start:end]
			dstCol.offsets[1] = int32(len(dstCol.data))
		}
	}
}
166161
func (v *TreeSelection) GetSelectedRows(model *TreeModel) *C.GList {
	return C.gtk_tree_selection_get_selected_rows(v.GTreeSelection, &model.GTreeModel)
}
1271915
func CopySelectedJoinRows(src *Chunk, innerColOffset, outerColOffset int, selected []bool, dst *Chunk) bool {
	if src.NumRows() == 0 {
		return false
	}

	numSelected := copySelectedInnerRows(innerColOffset, outerColOffset, src, selected, dst)
	copyOuterRows(innerColOffset, outerColOffset, src, numSelected, dst)
	dst.numVirtualRows += numSelected
	return numSelected > 0
}
1235586
func (db *Database) Compact(start []byte, limit []byte) error {
	return errors.New("unsupported operation")
}
7134
func InsertSpendingAddressRow(db *sql.DB, fundingTxHash string,
	fundingTxVoutIndex uint32, fundingTxTree int8, spendingTxHash string,
	spendingTxVinIndex uint32, vinDbID uint64, utxoData *dbtypes.UTXOData,
	checked, updateExisting, isValidMainchain bool,
	txType int16, updateFundingRow bool, spendingTXBlockTime dbtypes.TimeDef) (int64, error) {
	// Only allow atomic transactions to happen
	dbtx, err := db.Begin()
	if err != nil {
		return 0, fmt.Errorf(`unable to begin database transaction: %v`, err)
	}

	c, err := insertSpendingAddressRow(dbtx, fundingTxHash, fundingTxVoutIndex,
		fundingTxTree, spendingTxHash, spendingTxVinIndex, vinDbID, utxoData, checked,
		updateExisting, isValidMainchain, txType, updateFundingRow, spendingTXBlockTime)
	if err != nil {
		return 0, fmt.Errorf(`RowsAffected: %v + %v (rollback)`,
			err, dbtx.Rollback())
	}

	return c, dbtx.Commit()
}
116457
func CountMergedRowsCompact(rows []AddressRowCompact, txnView AddrTxnViewType) (numMerged int, err error) {
	var wrongDirection func(funding bool) bool
	switch txnView {
	case AddrMergedTxn:
		wrongDirection = func(_ bool) bool {
			return false
		}
	case AddrMergedTxnCredit:
		wrongDirection = func(funding bool) bool {
			return !funding
		}
	case AddrMergedTxnDebit:
		wrongDirection = func(funding bool) bool {
			return funding
		}
	default:
		return 0, fmt.Errorf("MergedTxnCount: requested count for non-merged view")
	}

	merged := make(map[chainhash.Hash]struct{})
	for i := range rows {
		if wrongDirection(rows[i].IsFunding) {
			continue
		}

		hash := rows[i].TxHash
		_, found := merged[hash]
		if !found {
			numMerged++
			merged[hash] = struct{}{}
			continue
		}
	}
	return
}