// 使用大端模式将int64转成byte数组
777229
func Uint64Tobytes(d uint64) []byte {
	data := make([]byte, 8)
	offset := 7
	for i := 7; i >= 0; i-- {
		data[offset-i] = byte((d >> uint(i*8)) & 0xff)
	}
	return data
}
488875
func Int64s(input []int64) []int64 {
	u := make([]int64, 0, len(input))
	m := make(map[int64]bool)

	for _, val := range input {
		if _, ok := m[val]; !ok {
			m[val] = true
			u = append(u, val)
		}
	}

	return u
}
268854
func (p *parserMixin) Int64() (target *int64) {
	target = new(int64)
	p.Int64Var(target)
	return
}
1135476
func (f *Queries) Int64(key string) (int64, error) {
	s, err := f.String(key)
	if err != nil {
		return 0, err
	}
	v, err := strconv.ParseInt(s, 10, 64)
	return v, err
}
715564
func Uint64Bytes(v uint64) []byte {
	b := make([]byte, 8)
	PutUint64(b, v)
	return b
}
1176476
func Int64ToString(from int64) (string, error) {
	return strconv.FormatInt(int64(from), DefeultNumericBase), nil
}
205793
func Int64P(val string) (*int64, error) {
	i, err := Int64(val)
	if err != nil {
		return nil, err
	}
	return proto.Int64(i), nil
}
111768
func (n *NamespacedKV) Int64(key string) (int64, bool) {
	valBs, err := n.db.Get(n.prefixedKey(key), nil)
	if err != nil {
		return 0, false
	}
	val := binary.BigEndian.Uint64(valBs)
	return int64(val), true
}
1154619
func Uint64(b []byte) uint64 {
	if l := len(b); l != 8 {
		panic(fmt.Sprintf("Uint64: unexpected byte slice length: %d", l))
	}

	return *(*uint64)(unsafe.Pointer(&b[0]))
}
805159
func parseInt64(d []byte) (n int64) {
	if len(d) == 0 {
		return -1
	}
	for _, dec := range d {
		if dec < ascii_0 || dec > ascii_9 {
			return -1
		}
		n = n*10 + (int64(dec) - ascii_0)
	}
	return n
}
1116083
func Int64() int64 {
	var bs [8]byte
	_, err := io.ReadFull(cryptoRand.Reader, bs[:])
	if err != nil {
		panic("randomness failure: " + err.Error())
	}
	return int64(binary.BigEndian.Uint64(bs[:]))
}
423176
func (e *Encoder) EncodeInt64(n int64) error {
	return e.write8(codes.Int64, uint64(n))
}
853057
func (x *Big) Int64() (int64, bool) {
	if debug {
		x.validate()
	}

	if !x.IsFinite() {
		return 0, false
	}

	// x might be too large to fit into an int64 *now*, but rescaling x might
	// shrink it enough. See issue #20.
	if !x.isCompact() {
		xb := x.Int(nil)
		return xb.Int64(), xb.IsInt64()
	}

	u := x.compact
	if x.exp != 0 {
		var ok bool
		if u, ok = scalex(u, x.exp); !ok {
			return 0, false
		}
	}
	su := int64(u)
	if su >= 0 || x.Signbit() && su == -su {
		if x.Signbit() {
			su = -su
		}
		return su, true
	}
	return 0, false
}
402238
func Uint64ToBytes(v uint64) []byte {
	b := make([]byte, 8)
	binary.BigEndian.PutUint64(b, v)
	return b
}
505353
func BytesToInt64(buf []byte, offset int) int64 {
	l := len(buf[offset:])
	if l > uint64sz {
		l = uint64sz
	}
	r := int64(binary.BigEndian.Uint64(buf[offset : offset+l]))
	return r
}
1265107
func (p *TCompactProtocol) bytesToInt64(b []byte) int64 {
	return int64(binary.LittleEndian.Uint64(b))
}
35853
func (e *Encoding) EncodeInt64(n int64) string {
	var (
		b   = make([]byte, 0)
		rem int64
	)

	// Progressively divide by base, store remainder each time
	// Prepend as an additional character is the higher power
	for n > 0 {
		rem = n % base
		n = n / base
		b = append([]byte{e.encode[rem]}, b...)
	}

	s := string(b)
	if e.padding > 0 {
		s = e.pad(s, e.padding)
	}

	return s
}