msgpack

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Buffer

func Buffer(buf *bytes.Buffer, vec *Vector) error

Buffer 序列化到缓冲区

func Compress

func Compress(vec *Vector) ([]byte, error)

Compress 压缩(使用 msgpack 的压缩特性)

func Encode

func Encode(vec *Vector) ([]byte, error)

Encode 编码

func EncodeBatch

func EncodeBatch(vectors []*Vector) ([]byte, error)

EncodeBatch 批量编码

func EncodeInterface

func EncodeInterface(data VectorData) ([]byte, error)

EncodeInterface 编码接口数据

Types

type Serializer

type Serializer struct{}

Serializer Msgpack 序列化器

func NewSerializer

func NewSerializer() *Serializer

NewSerializer 创建序列化器

func (*Serializer) Deserialize

func (s *Serializer) Deserialize(data []byte) (*Vector, error)

Deserialize 反序列化向量

func (*Serializer) DeserializeBatch

func (s *Serializer) DeserializeBatch(data []byte) ([]*Vector, error)

DeserializeBatch 批量反序列化

func (*Serializer) Serialize

func (s *Serializer) Serialize(vec *Vector) ([]byte, error)

Serialize 序列化向量

func (*Serializer) SerializeBatch

func (s *Serializer) SerializeBatch(vectors []*Vector) ([]byte, error)

SerializeBatch 批量序列化

type Vector

type Vector struct {
	ID        string
	Vector    []float32
	Payload   map[string]interface{}
	Timestamp time.Time
}

Vector 向量数据结构

func BufferDecode

func BufferDecode(buf *bytes.Buffer) (*Vector, error)

BufferDecode 从缓冲区解码

func Decode

func Decode(data []byte) (*Vector, error)

Decode 解码

func DecodeBatch

func DecodeBatch(data []byte) ([]*Vector, error)

DecodeBatch 批量解码

func DecodeInterface

func DecodeInterface(data []byte) (*Vector, error)

DecodeInterface 解码接口数据

func Decompress

func Decompress(data []byte) (*Vector, error)

Decompress 解压缩

type VectorData

type VectorData interface {
	GetID() string
	GetVector() []float32
	GetPayload() map[string]interface{}
	GetTimestamp() time.Time
}

Serializer 接口实现

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL