# README
sample
feature interface
This is the interface of feature, defining the following functions:
- Type() DataType // return the data type of this feature
- GetInt64() (int64, error)
- GetFloat32() (float32, error)
- GetString() (string, error)
- GetInt64s() ([]int64, error)
- GetFloat32s() ([]float32, error)
- GetStrings() ([]string, error)
features interface
This is a set of features encapsulated with a map, defining the following functions:
- Keys() []string // return all the keys of features
- Get(string) Feature
- MarshalJSON() ([]byte, error)
- UnmarshalJSON(data []byte) error
immutable features
This is the generated features by reading from string and cannot be changed. This structure declutters the memory used to store the features, reduces memory fragmentation, and thus lowers the GC. The memory structure of each type is as follows:
int64
- 4byte: data type
- 4byte: not used
- 8byte: int64 value
int64 array
- 4byte: data type
- 4byte: not used
- 24byte: reflect.SliceHeader, reflect.SliceHeader.Data point to the data part
- data: int64 array data
float32
- 4byte: data type
- 4byte: float32 value
float32 array
- 4byte: data type
- 4byte: not used
- 24byte: reflect.SliceHeader, reflect.SliceHeader.Data point to the data part
- data: float32 array data
string
- 4byte: data type
- 4byte: not used
- 16byte: reflect.StringHeader, reflect.StringHeader.Data point to the data part
- data: string value data, due to memory alignment, the length is divisible by 8
string array
- 4byte: data type
- 4byte: not used
- 24byte: reflect.SliceHeader, reflect.SliceHeader.Data point to the string header part
- string heads: reflect.StringHeader array
- data: byte list values, due to memory alignment, the length is divisible by 8
mutable features
This is a changeable features struct, stored in the map. Nothing special to say. Immutable Features can be converted to mutable features.