// DoInt executes one Redis command and interpretes
// the result as int value.
427242
func (conn *Connection) DoInt(cmd string, args ...interface{}) (int, error) {
	result, err := conn.Do(cmd, args...)
	if err != nil {
		return 0, err
	}
	return result.IntAt(0)
}
1281607
func (rs *ResultSet) IntAt(index int) (int, error) {
	value, err := rs.ValueAt(index)
	if err != nil {
		return 0, err
	}
	return value.Int()
}
787958
func (d *defaulter) AsUint(v Valuer, dv uint) uint {
	value, err := v.Value()
	if err != nil {
		d.logValuerError(err)
		return dv
	}
	uivalue, err := strconv.ParseUint(value, 10, 0)
	if err != nil {
		d.logFormatError("uint", err)
		return dv
	}
	return uint(uivalue)
}
898681
func Main() int {
	return ParseAndRun(os.Stdout, os.Stderr, os.Stdin, os.Args[1:])
}
983574
func (stmt *OCI8Stmt) Exec(args []driver.Value) (r driver.Result, err error) {
	list := make([]namedValue, len(args))
	for i, v := range args {
		list[i] = namedValue{
			Ordinal: i + 1,
			Value:   v,
		}
	}
	return stmt.exec(context.Background(), list)
}
613682
func (e *RadixHashJoinExec) doInnerPartition(workerID int) {
	chkIdx, chkNum := workerID, e.innerResult.NumChunks()
	for ; chkIdx < chkNum; chkIdx += int(e.concurrency) {
		if e.finished.Load().(bool) {
			return
		}
		chk := e.innerResult.GetChunk(chkIdx)
		for srcRowIdx, partPtr := range e.innerRowPrts[chkIdx] {
			if partPtr == partPtr4NullKey {
				continue
			}
			partIdx, destRowIdx := partPtr.partitionIdx, partPtr.rowIdx
			part := e.innerParts[partIdx]
			part.Insert(int(destRowIdx), chk.GetRow(srcRowIdx))
		}
	}
}
978591
func (stmt *OCI8Stmt) NumInput() int {
	var bindCount C.ub4 // number of bind position
	_, err := stmt.ociAttrGet(unsafe.Pointer(&bindCount), C.OCI_ATTR_BIND_COUNT)
	if err != nil {
		return -1
	}

	return int(bindCount)
}
766353
func (s *StdoutClient) Total(stat string, value int64) error {
	return s.send(stat, "%d|t", value)
}
515224
func (mp *Proxy) doSet(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
	vals, _, err := sqlparser.ExtractSetValues(sql)
	if err != nil {
		return nil, err
	}

	for k, v := range vals {
		switch k.Key {
		case "autocommit":
			val, ok := v.(int64)
			if !ok {
				return nil, fmt.Errorf("unexpected value type for autocommit: %T", v)
			}
			switch val {
			case 0:
				session.Autocommit = false
			case 1:
				if !session.Autocommit && session.TransactionID != 0 {
					if err := mp.doCommit(ctx, session); err != nil {
						return nil, err
					}
				}
				session.Autocommit = true
			default:
				return nil, fmt.Errorf("unexpected value for autocommit: %d", val)
			}
		case "charset", "names":
			val, ok := v.(string)
			if !ok {
				return nil, fmt.Errorf("unexpected value type for charset/names: %T", v)
			}
			switch val {
			case "", "utf8", "utf8mb4", "latin1", "default":
				break
			default:
				return nil, fmt.Errorf("unexpected value for charset/names: %v", val)
			}
		default:
			log.Warningf("Ignored inapplicable SET %v = %v", k, v)
		}
	}

	return &sqltypes.Result{}, nil
}
722059
func Stdout(val io.Writer) OptionSet {
	return func(o *Options) {
		o.Stdout = val
	}
}
320060
func (t *Tx) Init(tx, rx []byte) {
	t.tx.Init(tx)
	t.rx.Init(rx)
}
150267
func (r *Redis) SetBit(key string, offset, value int) (int64, error) {
	rp, err := r.ExecuteCommand("SETBIT", key, offset, value)
	if err != nil {
		return 0, err
	}
	return rp.IntegerValue()
}
442701
func insertionSort(data sort.Interface, lo, hi int) {
	for i := lo + 1; i < hi+1; i++ {
		for j := i; j > lo && data.Less(j, j-1); j-- {
			data.Swap(j, j-1)
		}
	}
}
474858
func (b *redisBroker) Init(opts ...broker.Option) error {
	if b.pool != nil {
		return errors.New("redis: cannot init while connected")
	}

	for _, o := range opts {
		o(&b.opts)
	}

	return nil
}
991969
func (ctx *Context) QueryUint(key string, defaults ...uint) uint {
	return (*Queries)(ctx.req).MustUint(key, defaults...)
}
1369652
func (conn *Connection) Do(cmd string, args ...interface{}) (*ResultSet, error) {
	cmd = strings.ToLower(cmd)
	if strings.Contains(cmd, "subscribe") {
		return nil, errors.New(ErrUseSubscription, errorMessages)
	}
	err := conn.ensureProtocol()
	if err != nil {
		return nil, err
	}
	if conn.database.monitoring {
		m := monitoring.BeginMeasuring(identifier.Identifier("redis", "command", cmd))
		defer m.EndMeasuring()
	}
	err = conn.resp.sendCommand(cmd, args...)
	logCommand(cmd, args, err, conn.database.logging)
	if err != nil {
		return nil, err
	}
	result, err := conn.resp.receiveResultSet()
	return result, err
}
624196
func (dd *dictDecoder) init(size int, dict []byte) {
	*dd = dictDecoder{hist: dd.hist}

	if cap(dd.hist) < size {
		dd.hist = make([]byte, size)
	}
	dd.hist = dd.hist[:size]

	if len(dict) > len(dd.hist) {
		dict = dict[len(dict)-len(dd.hist):]
	}
	dd.wrPos = copy(dd.hist, dict)
	if dd.wrPos == len(dd.hist) {
		dd.wrPos = 0
		dd.full = true
	}
	dd.rdPos = dd.wrPos
}