MCPcopy
hub / github.com/uber/aresdb / NewVector

Function NewVector

memstore/vectors/vector.go:57–72  ·  view source on GitHub ↗

NewVector creates a vector with the specified bits per unit and size(capacity). The majority of its storage space is managed in C.

(dataType common.DataType, size int)

Source from the content-addressed store, hash-verified

55// NewVector creates a vector with the specified bits per unit and size(capacity).
56// The majority of its storage space is managed in C.
57func NewVector(dataType common.DataType, size int) *Vector {
58 unitBits := common.DataTypeBits(dataType)
59 bytes := CalculateVectorBytes(dataType, size)
60
61 buffer := cgoutils.HostAlloc(bytes)
62
63 return &Vector{
64 DataType: dataType,
65 CmpFunc: common.GetCompareFunc(dataType),
66 unitBits: unitBits,
67 Size: size,
68 Bytes: bytes,
69 buffer: uintptr(buffer),
70 minValue: math.MaxUint32,
71 }
72}
73
74// CalculateVectorBytes calculates bytes the vector will occupy given data type and size without actual allocation.
75func CalculateVectorBytes(dataType common.DataType, size int) int {

Callers 9

toVectorPartyFunction · 0.92
ReadMethod · 0.92
AllocateMethod · 0.92
toVectorMethod · 0.92
AllocateMethod · 0.92
AllocateMethod · 0.92
ReadMethod · 0.92
vector_test.goFile · 0.85

Calls 4

DataTypeBitsFunction · 0.92
HostAllocFunction · 0.92
GetCompareFuncFunction · 0.92
CalculateVectorBytesFunction · 0.85

Tested by

no test coverage detected