Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x float32) float32
- func Assert(x bool, y string)
- func Ast(fileName string) map[int]string
- func BIT(x interface{}) interface{}
- func BIT64(x interface{}) interface{}
- func Bool(str string) bool
- func BytesToFloat32(data []byte) float32
- func BytesToFloat64(data []byte) float64
- func BytesToInt(data []byte) int
- func BytesToInt16(data []byte) int16
- func BytesToInt64(data []byte) int64
- func ChechErr(err error)
- func Clamp(val, low, high int) int
- func DecryptName1(strName string) uint32
- func DecryptName2(strName string) uint32
- func Float32(str string) float32
- func Float32ToByte(val float32) []byte
- func Float64(str string) float64
- func Float64ToByte(val float64) []byte
- func Get(url string, params ...Kv) ([]byte, error)
- func GetAvlHeight(tree *AvlBitTree) int
- func GetClassName(rType reflect.Type) string
- func GetDBTime(strTime string) *time.Time
- func GetLanAddr(ip string) string
- func GetMessageCode(strName string, m1 *uint32, m2 *uint32)
- func GetMessageCode1(strName string) uint32
- func GetMessageCode2(strName string) uint32
- func GetNextTime(intervalType int) time.Time
- func Htonl(n uint64) []byte
- func Htons(n uint16) []byte
- func IFAssert(x bool, y string)
- func InsertSort(arr []int)
- func Int(str string) int
- func Int16ToBytes(val int16) []byte
- func Int64(str string) int64
- func Int64ToBytes(val int64) []byte
- func IntToBytes(val int) []byte
- func IntToInt32(val []int) []int32
- func LoadData(obj interface{}, file *DataFile) bool
- func MD5(str string) string
- func Max(a, b int) int
- func MaxHeap(arr []int)
- func MiddleAvlPrint(tree *AvlBitTree)
- func MiddlePrint(tree *BitTree)
- func Min(a, b int) int
- func MinHeap(arr []int)
- func ParseTag(sf reflect.StructField, tag string) map[string]string
- func ParseUUID(id int64) (ts int64, workerId int64, seq int64)
- func PathExists(path string) bool
- func PopHeap(arr []int, bMax bool) []int
- func Post(url string, data []byte, contentType string) ([]byte, error)
- func PrepareCryptBuffer()
- func QuickSort(arr []int, left int, right int)
- func QuickSort2(arr []int, left, right int)
- func RandF[T ~float32 | ~float64](i T, n T) T
- func RandI[T RandType](i T, n T) T
- func ReadConf(path string, data interface{}) bool
- func SelectSort(arr []int)
- func SetTcpEnd(buff []byte) []byte
- func Time(str string) int64
- func ToHash(str string) uint32
- func ToString(value interface{}) string
- func TraceCode(code ...interface{})
- func WalkDir(dirpath string, filesVec *vector.Vector)
- type AvlBitTree
- func DeleteAvlTree(tree *AvlBitTree, data int) *AvlBitTree
- func InsertAvlBitTree(tree *AvlBitTree, data int) *AvlBitTree
- func LR_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
- func L_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
- func RL_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
- func R_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
- type BitMap
- type BitStream
- func (b *BitStream) BuildPacketStream(buffer []byte, writeSize int) bool
- func (b *BitStream) GetBuffer() []byte
- func (b *BitStream) GetBytePtr() []byte
- func (b *BitStream) GetCurPos() int
- func (b *BitStream) GetPosition() int
- func (b *BitStream) GetReadByteSize() int
- func (b *BitStream) GetStreamSize() int
- func (b *BitStream) ReadBits(bitCount int) []byte
- func (b *BitStream) ReadFlag() bool
- func (b *BitStream) ReadFloat() float32
- func (b *BitStream) ReadFloat64() float64
- func (b *BitStream) ReadInt(bitCount int) int
- func (b *BitStream) ReadInt64(bitCount int) int64
- func (b *BitStream) ReadString() string
- func (b *BitStream) SetPosition(pos int) bool
- func (b *BitStream) WriteBits(bitPtr []byte, bitCount int)
- func (b *BitStream) WriteFlag(value bool) bool
- func (b *BitStream) WriteFloat(value float32)
- func (b *BitStream) WriteFloat64(value float64)
- func (b *BitStream) WriteInt(value int, bitCount int)
- func (b *BitStream) WriteInt64(value int64, bitCount int)
- func (b *BitStream) WriteString(value string)
- type BitTree
- type Data
- func (d *Data) Enum(datacol string) int
- func (d *Data) Float32(datacol string) float32
- func (d *Data) Float32Array(datacol string) []float32
- func (d *Data) Float64(datacol string) float64
- func (d *Data) Float64Array(datacol string) []float64
- func (d *Data) Int(datacol string) int
- func (d *Data) Int16(datacol string) int16
- func (d *Data) Int16Array(datacol string) []int16
- func (d *Data) Int64(datacol string) int64
- func (d *Data) Int64Array(datacol string) []int64
- func (d *Data) Int8(datacol string) int8
- func (d *Data) Int8Array(datacol string) []int8
- func (d *Data) IntArray(datacol string) []int
- func (d *Data) String(datacol string) string
- func (d *Data) StringArray(datacol string) []string
- type DataFile
- type Dh
- type HashRing
- type IAvlBitTree
- type IBitMap
- type IBitStream
- type IBitTree
- type IDateFile
- type IDh
- type IHashRing
- type ILog
- type ISnowflake
- type IStuHashRing
- type IVersion
- type IWorkIdQue
- type Kv
- type LG_TYPE
- type Locker
- type Log
- func (l *Log) Fatal(v1 ...interface{})
- func (l *Log) Fatalf(format string, params ...interface{})
- func (l *Log) Fatalln(v1 ...interface{})
- func (l *Log) GetSuffix(nType LG_TYPE) string
- func (l *Log) Init(fileName string) bool
- func (l *Log) Print(v1 ...interface{})
- func (l *Log) Printf(format string, params ...interface{})
- func (l *Log) Println(v1 ...interface{})
- func (l *Log) Write(nType LG_TYPE)
- func (l *Log) WriteFile(nType LG_TYPE)
- type PProf
- type Rand
- type RandType
- type Snowflake
- type StubHashRing
- type Version
- type WorkIdQue
Constants ¶
const ( NONE_ERROR = iota VERSION_ERROR //版本不正确 ACCOUNT_NOEXIST //账号不存在 PASSWORD_ERROR //密码不正确 )
const ( Bit8 = 8 Bit16 = 16 Bit32 = 32 Bit64 = 64 Bit128 = 128 MAX_PACKET = 1 * 1024 * 1024 //1MB MAX_CLIENT_PACKET = 10 * 1024 //10KB )
const ( INT_MAX = int(2147483647) TCP_HEAD_SIZE = 4 //解决tpc粘包半包,包头固定长度 TCP_END = "💞♡" //解决tpc粘包半包,特殊结束标志,pb采用Varint编码高位有特殊含义 )
const ( DATA_END = "data_end" DATA_END_LENGTH = len(DATA_END) //data结束标记 )
const ( DType_none = iota DType_String = iota DType_Enum = iota DType_S8 = iota DType_S16 = iota DType_S32 = iota DType_F32 = iota DType_F64 = iota DType_S64 = iota DType_StringArray = iota DType_S8Array = iota DType_S16Array = iota DType_S32Array = iota DType_F32Array = iota DType_F64Array = iota DType_S64Array = iota )
datatype
const ( INTERVAL_DAY = iota //当前时间的第二天 INTERVAL_WEEK = iota //当前时间的下周一 INTERVAL_MONTH = iota //当前时间的下一月第一天) INTERVAL_YEAR = iota //当前时间的下一年第一天) TIME_SET_MAX_VAL = iota //类型最大值 )
const (
BUILD_NO = "1,5,1,1"
)
const (
CRYPT_BUFFER_SIZE = 0x500
)
const (
PATH = "log"
)
const (
REPLICASNUM = 5
)
const (
WorkeridMax = workeridMax //集群自增量
)
* Snowflake * * 1 42 54 64 * +-----------------------------------------------+----------------+---------------+ * | timestamp(ms) | workerid | sequence | * +-----------------------------------------------+----------------+---------------+ * | 0000000000 0000000000 0000000000 0000000000 0 | 0000000000 00 | 0000000000 | * +-----------------------------------------------+----------------+---------------+ * * 1. 41位时间截(毫秒级),注意这是时间截的差值(当前时间截 - 开始时间截)。可以使用约69年: (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69 * 2. 12位数据机器位,可以部署在4096个节点 * 3. 10位序列,毫秒内的计数,同一机器,同一时间截并发1024个序号
Variables ¶
var ( SEVERNAME string TCP_END_LENGTH = len([]byte(TCP_END)) //tcp结束标志长度 )
var (
CryptBuffer []uint32
)
var ErrEmptyRing = errors.New("empty ring")
ErrEmptyRing is the error returned when trying to get an element when nothing has been added to hash.
var (
UUID = ISnowflake(&Snowflake{})
)
Functions ¶
func BytesToFloat32 ¶
func BytesToFloat64 ¶
func BytesToInt64 ¶
func DecryptName1 ¶
func DecryptName2 ¶
func GetAvlHeight ¶
func GetAvlHeight(tree *AvlBitTree) int
func GetClassName ¶
func GetLanAddr ¶
func GetMessageCode ¶
func GetMessageCode1 ¶
func GetMessageCode2 ¶
func GetNextTime ¶
func MiddleAvlPrint ¶
func MiddleAvlPrint(tree *AvlBitTree)
func MiddlePrint ¶
func MiddlePrint(tree *BitTree)
func PathExists ¶
func PrepareCryptBuffer ¶
func PrepareCryptBuffer()
Types ¶
type AvlBitTree ¶
type AvlBitTree struct {
// contains filtered or unexported fields
}
--------------avltree---------//
func DeleteAvlTree ¶
func DeleteAvlTree(tree *AvlBitTree, data int) *AvlBitTree
func InsertAvlBitTree ¶
func InsertAvlBitTree(tree *AvlBitTree, data int) *AvlBitTree
func LR_Rorate ¶
func LR_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
func L_Rorate ¶
func L_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
func RL_Rorate ¶
func RL_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
func R_Rorate ¶
func R_Rorate(tree *AvlBitTree, root **AvlBitTree) *AvlBitTree
func (*AvlBitTree) Equal ¶
func (this *AvlBitTree) Equal(data int) bool
func (*AvlBitTree) Less ¶
func (this *AvlBitTree) Less(data int) bool
type BitStream ¶
type BitStream struct {
// contains filtered or unexported fields
}
func NewBitStream ¶
func (*BitStream) BuildPacketStream ¶
func (*BitStream) GetBytePtr ¶
func (*BitStream) GetPosition ¶
func (*BitStream) GetReadByteSize ¶
func (*BitStream) GetStreamSize ¶
func (*BitStream) ReadFloat64 ¶
func (*BitStream) ReadString ¶
func (*BitStream) SetPosition ¶
func (*BitStream) WriteFloat ¶
func (*BitStream) WriteFloat64 ¶
func (*BitStream) WriteInt64 ¶
func (*BitStream) WriteString ¶
type BitTree ¶
type BitTree struct {
// contains filtered or unexported fields
}
-----------bittreee-------------------//
func DeleteTree ¶
func InsertBitTree ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
func (*Data) Float32Array ¶
func (*Data) Float64Array ¶
func (*Data) Int16Array ¶
func (*Data) Int64Array ¶
func (*Data) StringArray ¶
type DataFile ¶
type DataFile struct { RecordNum int //记录数量 ColumNum int //列数量 // contains filtered or unexported fields }
func (*DataFile) GetData ¶
***************************
格式: 头文件: 1、总记录数(int) 2、总字段数(int) 字段格式: 1、字段长度(int) 2、字读数据类型(int->2,string->1,enum->3,float->4) 3、字段内容(int,string)
************************
func (*DataFile) ReadDataFile ¶
func (*DataFile) ReadDataInit ¶
func (d *DataFile) ReadDataInit()
type Dh ¶
func (*Dh) ExchangePubk ¶
type HashRing ¶
HashRing holds the information about the members of the consistent hash ring.
func NewHashRing ¶
func NewHashRing() *HashRing
New creates a new HashRing( object with a default setting of 20 replicas for each entry. To change the number of replicas, set NumberOfReplicas before adding entries.
type IAvlBitTree ¶
--------------avltree---------//
type IBitStream ¶
type IBitStream interface { BuildPacketStream([]byte, int) bool GetBuffer() []byte GetBytePtr() []byte GetReadByteSize() int GetCurPos() int GetPosition() int GetStreamSize() int SetPosition(int) bool WriteBits([]byte, int) ReadBits(int) []byte WriteInt(int, int) ReadInt(int) int ReadFlag() bool WriteFlag(bool) bool WriteString(string) ReadString() string WriteInt64(int64, int) ReadInt64(int) int64 WriteFloat(float32) ReadFloat() float32 WriteFloat64(float64) ReadFloat64() float64 // contains filtered or unexported methods }
type ISnowflake ¶
type IStuHashRing ¶
use for stubring
type PProf ¶
type PProf struct { }
func (*PProf) Init ¶
func (p *PProf) Init()
http://localhost:6060/debug/pprof/ http://localhost:6060/debug/pprof/heap go tool pprof -inuse_space http://localhost:6060/debug/pprof/heap go tool pprof http://localhost:6060/debug/pprof/heap?debug=1
type StubHashRing ¶
type StubHashRing struct {
// contains filtered or unexported fields
}
HashRing holds the information about the members of the consistent hash ring.
func (*StubHashRing) Init ¶
func (h *StubHashRing) Init(endpoints []string)
Add inserts a string element in the consistent hash.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
var (
VERSION Version
)