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)
| 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. |
| 57 | func 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. |
| 75 | func CalculateVectorBytes(dataType common.DataType, size int) int { |
no test coverage detected