stl

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SizeOfMany

func SizeOfMany[T any](cnt int) int

func Sizeof

func Sizeof[T any]() int

Types

type Bytes

type Bytes struct {
	// Specify type size
	// Positive if it is fixed type
	// Negtive if it is varlen type
	TypeSize int

	// Specify whether it retains a window
	AsWindow bool
	// Window offset and length
	WinOffset int
	WinLength int

	// Used only when IsFixedType is false
	// Header store data if the size is less than VarlenaSize
	Header []types.Varlena

	// When IsFixedType is true, here is the data storage
	// When IsFixedType is false, here is the data storage for big data
	// When AsWindow is true, here stores all big data
	Storage []byte
}

func NewBytesWithTypeSize added in v0.6.0

func NewBytesWithTypeSize(sz int) *Bytes

func NewFixedTypeBytes added in v0.6.0

func NewFixedTypeBytes[T any]() *Bytes

func (*Bytes) GetVarValueAt added in v0.6.0

func (bs *Bytes) GetVarValueAt(i int) []byte

func (*Bytes) HeaderBuf added in v0.6.0

func (bs *Bytes) HeaderBuf() (buf []byte)

func (*Bytes) HeaderSize added in v0.6.0

func (bs *Bytes) HeaderSize() int

func (*Bytes) IsFixedType added in v0.6.0

func (bs *Bytes) IsFixedType() bool

func (*Bytes) IsWindow added in v0.6.0

func (bs *Bytes) IsWindow() bool

func (*Bytes) Length

func (bs *Bytes) Length() int

func (*Bytes) SetHeaderBuf added in v0.6.0

func (bs *Bytes) SetHeaderBuf(buf []byte)

func (*Bytes) SetStorageBuf added in v0.6.0

func (bs *Bytes) SetStorageBuf(buf []byte)

func (*Bytes) Size added in v0.6.0

func (bs *Bytes) Size() int

func (*Bytes) StorageBuf added in v0.6.0

func (bs *Bytes) StorageBuf() []byte

func (*Bytes) StorageSize added in v0.6.0

func (bs *Bytes) StorageSize() int

func (*Bytes) ToWindow added in v0.6.0

func (bs *Bytes) ToWindow(offset, length int)

func (*Bytes) Window

func (bs *Bytes) Window(offset, length int) *Bytes

type Callers

type Callers struct {
	// contains filtered or unexported fields
}

func GetCalllers

func GetCalllers(skip int) *Callers

func (*Callers) Close

func (c *Callers) Close()

func (*Callers) String

func (c *Callers) String() string

type Vector

type Vector[T any] interface {
	// Close free the vector allocated memory
	// Caller must call Close() or a memory leak will occur
	Close()

	// Clone deep copy data from offset to offset+length and create a new vector
	Clone(offset, length int, allocator ...*mpool.MPool) Vector[T]

	// If share is true, vector release allocated memory and use the buf and its data storage
	// If share is false, vector will copy the data from buf to its own data storage
	ReadBytes(data *Bytes, share bool)

	// Reset resets the buffer to be empty
	// but it retains the underlying storage for use by future writes
	Reset()

	// IsView returns true if the vector shares the data storage with external buffer
	IsView() bool

	// TODO
	Bytes() *Bytes
	WindowAsBytes(offset, length int) *Bytes

	// Data returns the underlying data storage buffer
	// For Vector[[]byte], it only returns the data buffer
	Data() []byte
	// DataWindow returns a data window [offset, offset+length)
	DataWindow(offset, length int) []byte
	// Slice returns the underlying data storage of type T
	Slice() []T
	SliceWindow(offset, length int) []T

	// Get returns the specified element at i
	// Note: If T is []byte, make sure not to use v after the vector is closed
	Get(i int) (v T)
	// Append appends a element into the vector
	// If the prediction length is large than Capacity, it will cause the underlying memory reallocation.
	// Reallocation:
	// 1. Apply a new memory node from allocator
	// 2. Copy existing data into new buffer
	// 3. Swap owned memory node
	// 4. Free old memory node
	Append(v T)
	// Append appends many elements into the vector
	AppendMany(vals ...T)
	// Append updates a element at i to a new value
	// For T=[]byte, Update may introduce a underlying memory reallocation
	Update(i int, v T)
	// Delete deletes a element at i
	Delete(i int) (deleted T)
	// BatchDelete delete rows from rowGen
	// cnt specifies the total delete count
	BatchDelete(rowGen common.RowGen, cnt int)
	BatchDeleteInts(sels ...int)
	BatchDeleteUint32s(sels ...uint32)

	// Returns the underlying memory allocator
	GetAllocator() *mpool.MPool
	// Returns the capacity, which is always >= Length().
	// It is related to the number of elements. Same as C++ std::vector::capacity
	Capacity() int
	// Returns the number of elements in the vertor
	Length() int
	// Return the space allocted
	Allocated() int

	String() string
	Desc() string

	// WriteTo writes data to w until the buffer is drained or an error occurs
	WriteTo(io.Writer) (int64, error)
	// ReadFrom reads data from r until EOF and appends it to the buffer, growing
	// the buffer as needed.
	ReadFrom(io.Reader) (int64, error)
	InitFromSharedBuf(buf []byte) (int64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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