Documentation
¶
Index ¶
- Constants
- func BatchGet[T any](b *Batch[T]) *T
- func ErrStream(stream string) string
- func GrowBytes(in []byte, need int) []byte
- func GrowInts(in []int) []int
- func GrowObjs(in []uint8, need int, goType *GoType) []uint8
- func GrowPointers(in []string, need int) []string
- func GrowStrings(in []string, need int) []string
- func Marshal(in interface{}) (bs []byte, err error)
- func Unmarshal(bsIn []byte, in interface{}) (err error)
- func UnmarshalString(bs string, in interface{}) (err error)
- type Batch
- type BatchObj
- type GoEface
- type GoIface
- type GoItab
- type GoPtrType
- type GoType
- type PoolStore
- func (ps PoolStore) GetInts() []int
- func (ps PoolStore) GetNoscan() []byte
- func (ps PoolStore) GetObjs(goType *GoType) []uint8
- func (ps PoolStore) GetPointers() []string
- func (ps PoolStore) GetStrings() []string
- func (ps PoolStore) Idx(idx uintptr) (p unsafe.Pointer)
- func (ps PoolStore) SetInts(strs []int)
- func (ps PoolStore) SetNoscan(pool []byte)
- func (ps PoolStore) SetObjs(in []uint8) PoolStore
- func (ps PoolStore) SetPointers(strs []string)
- func (ps PoolStore) SetStrings(strs []string)
- type RCU
- type SliceHeader
- type Store
- type StringHeader
- type TagInfo
- type TypeBuilder
- func (b *TypeBuilder) AddBool(name string) *TypeBuilder
- func (b *TypeBuilder) AddField(field string, typ reflect.Type) *TypeBuilder
- func (b *TypeBuilder) AddFloat64(name string) *TypeBuilder
- func (b *TypeBuilder) AddInt64(name string) *TypeBuilder
- func (b *TypeBuilder) AddString(name string) *TypeBuilder
- func (b *TypeBuilder) AppendBool(name string, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendField(name string, typ reflect.Type, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendFloat64(name string, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendInt64(name string, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendIntSlice(name string, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendPointer(name string, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendString(name string, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) AppendTagField(typ reflect.Type, lazyOffset *uintptr) *TypeBuilder
- func (b *TypeBuilder) Build() reflect.Type
- func (b *TypeBuilder) Init()
- func (b *TypeBuilder) Interface() interface{}
- func (b *TypeBuilder) New() unsafe.Pointer
- func (b *TypeBuilder) NewFromPool() unsafe.Pointer
- func (b *TypeBuilder) NewSlice() unsafe.Pointer
- func (b *TypeBuilder) PInterface() (unsafe.Pointer, interface{})
- type Value
Constants ¶
View Source
const SPoolN = 1024 // * 1024
Variables ¶
This section is empty.
Functions ¶
func GrowPointers ¶
func GrowStrings ¶
func UnmarshalString ¶
UnmarshalString Unmarshal string
Types ¶
type BatchObj ¶
func NewBatchObj ¶
type GoEface ¶
func UnpackEface ¶
func UnpackEface(v interface{}) GoEface
type GoType ¶
type GoType struct { Size uintptr PtrData uintptr Hash uint32 Flags uint8 Align uint8 FieldAlign uint8 KindFlags uint8 Traits unsafe.Pointer GCData *byte Str int32 PtrToSelf int32 }
func UnpackNonEface ¶
func UnpackType ¶
type PoolStore ¶
type PoolStore struct {
// contains filtered or unexported fields
}
func (PoolStore) GetPointers ¶
func (PoolStore) GetStrings ¶
func (PoolStore) SetPointers ¶
func (PoolStore) SetStrings ¶
type RCU ¶
type RCU[T uintptr | uint32 | string | int, V any] struct { // contains filtered or unexported fields }
RCU 依据 Read Copy Update 原理实现
type StringHeader ¶
type TagInfo ¶
type TagInfo struct { TagName string // BaseType reflect.Type // BaseKind reflect.Kind // 次成员可能是 **string,[]int 等这种复杂类型,这个 用来指示 "最里层" 的类型 Offset uintptr //偏移量 TypeSize int // StringTag bool // `json:"field,string"`: 此情形下,需要把struct的int转成json的string OmitemptyTag bool // `json:"some_field,omitempty"` /* ChildList: 遍历 map 性能较差,加个 list */ Children map[string]*TagInfo ChildList []*TagInfo // 遍历的顺序和速度 SPool sync.Pool // TODO:slice pool 和 store.pool 放在一起吧,通过 id 来获取获取 pool,并把剩余的”垃圾“放回 sync.Pool 中共下次复用 SPoolN int32 // contains filtered or unexported fields }
TagInfo 拥有tag的struct的成员的解析结果
func NewStructTagInfo ¶
NewStructTagInfo 解析struct的tag字段,并返回解析的结果
每个 struct 都搞一个 pointerCacheType,在使用的时候直接获取; 再搞一个 slicePool 在是 slice 时使用; 二者不会同一时刻出现,是不是可以合并为同一个值?
func (*TagInfo) GetChildFromMap ¶
type TypeBuilder ¶
构造器
func NewTypeBuilder ¶
func NewTypeBuilder() *TypeBuilder
func (*TypeBuilder) AddBool ¶
func (b *TypeBuilder) AddBool(name string) *TypeBuilder
func (*TypeBuilder) AddField ¶
func (b *TypeBuilder) AddField(field string, typ reflect.Type) *TypeBuilder
添加字段
func (*TypeBuilder) AddFloat64 ¶
func (b *TypeBuilder) AddFloat64(name string) *TypeBuilder
func (*TypeBuilder) AddInt64 ¶
func (b *TypeBuilder) AddInt64(name string) *TypeBuilder
func (*TypeBuilder) AddString ¶
func (b *TypeBuilder) AddString(name string) *TypeBuilder
func (*TypeBuilder) AppendBool ¶
func (b *TypeBuilder) AppendBool(name string, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendField ¶
func (b *TypeBuilder) AppendField(name string, typ reflect.Type, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendFloat64 ¶
func (b *TypeBuilder) AppendFloat64(name string, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendInt64 ¶
func (b *TypeBuilder) AppendInt64(name string, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendIntSlice ¶
func (b *TypeBuilder) AppendIntSlice(name string, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendPointer ¶
func (b *TypeBuilder) AppendPointer(name string, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendString ¶
func (b *TypeBuilder) AppendString(name string, lazyOffset *uintptr) *TypeBuilder
func (*TypeBuilder) AppendTagField ¶
func (b *TypeBuilder) AppendTagField(typ reflect.Type, lazyOffset *uintptr) *TypeBuilder
针对 slice,要添加一个 [4]type 的空间作为预分配的资源
func (*TypeBuilder) Interface ¶
func (b *TypeBuilder) Interface() interface{}
func (*TypeBuilder) NewFromPool ¶
func (b *TypeBuilder) NewFromPool() unsafe.Pointer
TODO: 此处也可以使用 NewBatch 来提高性能? 提升 10ns ?
func (*TypeBuilder) PInterface ¶
func (b *TypeBuilder) PInterface() (unsafe.Pointer, interface{})
Click to show internal directories.
Click to hide internal directories.