mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
35ea775c14
See also #31293 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
435 lines
9.0 KiB
Go
435 lines
9.0 KiB
Go
// Code generated by go generate; DO NOT EDIT
|
|
// This file is generated by go generated
|
|
package column
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
|
"github.com/milvus-io/milvus/client/v2/entity"
|
|
|
|
"github.com/cockroachdb/errors"
|
|
)
|
|
|
|
// ColumnBinaryVector generated columns type for BinaryVector
|
|
type ColumnBinaryVector struct {
|
|
ColumnBase
|
|
name string
|
|
dim int
|
|
values [][]byte
|
|
}
|
|
|
|
// Name returns column name
|
|
func (c *ColumnBinaryVector) Name() string {
|
|
return c.name
|
|
}
|
|
|
|
// Type returns column entity.FieldType
|
|
func (c *ColumnBinaryVector) Type() entity.FieldType {
|
|
return entity.FieldTypeBinaryVector
|
|
}
|
|
|
|
// Len returns column data length
|
|
func (c *ColumnBinaryVector) Len() int {
|
|
return len(c.values)
|
|
}
|
|
|
|
func (c *ColumnBinaryVector) Slice(start, end int) Column {
|
|
l := c.Len()
|
|
if start > l {
|
|
start = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
return &ColumnBinaryVector{
|
|
ColumnBase: c.ColumnBase,
|
|
name: c.name,
|
|
dim: c.dim,
|
|
values: c.values[start:end],
|
|
}
|
|
}
|
|
|
|
// Dim returns vector dimension
|
|
func (c *ColumnBinaryVector) Dim() int {
|
|
return c.dim
|
|
}
|
|
|
|
// Get returns values at index as interface{}.
|
|
func (c *ColumnBinaryVector) Get(idx int) (interface{}, error) {
|
|
if idx < 0 || idx >= c.Len() {
|
|
return nil, errors.New("index out of range")
|
|
}
|
|
return c.values[idx], nil
|
|
}
|
|
|
|
// AppendValue append value into column
|
|
func (c *ColumnBinaryVector) AppendValue(i interface{}) error {
|
|
v, ok := i.([]byte)
|
|
if !ok {
|
|
return fmt.Errorf("invalid type, expected []byte, got %T", i)
|
|
}
|
|
c.values = append(c.values, v)
|
|
|
|
return nil
|
|
}
|
|
|
|
// Data returns column data
|
|
func (c *ColumnBinaryVector) Data() [][]byte {
|
|
return c.values
|
|
}
|
|
|
|
// FieldData return column data mapped to schemapb.FieldData
|
|
func (c *ColumnBinaryVector) FieldData() *schemapb.FieldData {
|
|
fd := &schemapb.FieldData{
|
|
Type: schemapb.DataType_BinaryVector,
|
|
FieldName: c.name,
|
|
}
|
|
|
|
data := make([]byte, 0, len(c.values)*c.dim)
|
|
|
|
for _, vector := range c.values {
|
|
data = append(data, vector...)
|
|
}
|
|
|
|
fd.Field = &schemapb.FieldData_Vectors{
|
|
Vectors: &schemapb.VectorField{
|
|
Dim: int64(c.dim),
|
|
|
|
Data: &schemapb.VectorField_BinaryVector{
|
|
BinaryVector: data,
|
|
},
|
|
},
|
|
}
|
|
return fd
|
|
}
|
|
|
|
// NewColumnBinaryVector auto generated constructor
|
|
func NewColumnBinaryVector(name string, dim int, values [][]byte) *ColumnBinaryVector {
|
|
return &ColumnBinaryVector{
|
|
name: name,
|
|
dim: dim,
|
|
values: values,
|
|
}
|
|
}
|
|
|
|
// ColumnFloatVector generated columns type for FloatVector
|
|
type ColumnFloatVector struct {
|
|
ColumnBase
|
|
name string
|
|
dim int
|
|
values [][]float32
|
|
}
|
|
|
|
// Name returns column name
|
|
func (c *ColumnFloatVector) Name() string {
|
|
return c.name
|
|
}
|
|
|
|
// Type returns column entity.FieldType
|
|
func (c *ColumnFloatVector) Type() entity.FieldType {
|
|
return entity.FieldTypeFloatVector
|
|
}
|
|
|
|
// Len returns column data length
|
|
func (c *ColumnFloatVector) Len() int {
|
|
return len(c.values)
|
|
}
|
|
|
|
func (c *ColumnFloatVector) Slice(start, end int) Column {
|
|
l := c.Len()
|
|
if start > l {
|
|
start = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
return &ColumnFloatVector{
|
|
ColumnBase: c.ColumnBase,
|
|
name: c.name,
|
|
dim: c.dim,
|
|
values: c.values[start:end],
|
|
}
|
|
}
|
|
|
|
// Dim returns vector dimension
|
|
func (c *ColumnFloatVector) Dim() int {
|
|
return c.dim
|
|
}
|
|
|
|
// Get returns values at index as interface{}.
|
|
func (c *ColumnFloatVector) Get(idx int) (interface{}, error) {
|
|
if idx < 0 || idx >= c.Len() {
|
|
return nil, errors.New("index out of range")
|
|
}
|
|
return c.values[idx], nil
|
|
}
|
|
|
|
// AppendValue append value into column
|
|
func (c *ColumnFloatVector) AppendValue(i interface{}) error {
|
|
v, ok := i.([]float32)
|
|
if !ok {
|
|
return fmt.Errorf("invalid type, expected []float32, got %T", i)
|
|
}
|
|
c.values = append(c.values, v)
|
|
|
|
return nil
|
|
}
|
|
|
|
// Data returns column data
|
|
func (c *ColumnFloatVector) Data() [][]float32 {
|
|
return c.values
|
|
}
|
|
|
|
// FieldData return column data mapped to schemapb.FieldData
|
|
func (c *ColumnFloatVector) FieldData() *schemapb.FieldData {
|
|
fd := &schemapb.FieldData{
|
|
Type: schemapb.DataType_FloatVector,
|
|
FieldName: c.name,
|
|
}
|
|
|
|
data := make([]float32, 0, len(c.values)*c.dim)
|
|
|
|
for _, vector := range c.values {
|
|
data = append(data, vector...)
|
|
}
|
|
|
|
fd.Field = &schemapb.FieldData_Vectors{
|
|
Vectors: &schemapb.VectorField{
|
|
Dim: int64(c.dim),
|
|
|
|
Data: &schemapb.VectorField_FloatVector{
|
|
FloatVector: &schemapb.FloatArray{
|
|
Data: data,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
return fd
|
|
}
|
|
|
|
// NewColumnFloatVector auto generated constructor
|
|
func NewColumnFloatVector(name string, dim int, values [][]float32) *ColumnFloatVector {
|
|
return &ColumnFloatVector{
|
|
name: name,
|
|
dim: dim,
|
|
values: values,
|
|
}
|
|
}
|
|
|
|
// ColumnFloat16Vector generated columns type for Float16Vector
|
|
type ColumnFloat16Vector struct {
|
|
ColumnBase
|
|
name string
|
|
dim int
|
|
values [][]byte
|
|
}
|
|
|
|
// Name returns column name
|
|
func (c *ColumnFloat16Vector) Name() string {
|
|
return c.name
|
|
}
|
|
|
|
// Type returns column entity.FieldType
|
|
func (c *ColumnFloat16Vector) Type() entity.FieldType {
|
|
return entity.FieldTypeFloat16Vector
|
|
}
|
|
|
|
// Len returns column data length
|
|
func (c *ColumnFloat16Vector) Len() int {
|
|
return len(c.values)
|
|
}
|
|
|
|
func (c *ColumnFloat16Vector) Slice(start, end int) Column {
|
|
l := c.Len()
|
|
if start > l {
|
|
start = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
return &ColumnFloat16Vector{
|
|
ColumnBase: c.ColumnBase,
|
|
name: c.name,
|
|
dim: c.dim,
|
|
values: c.values[start:end],
|
|
}
|
|
}
|
|
|
|
// Dim returns vector dimension
|
|
func (c *ColumnFloat16Vector) Dim() int {
|
|
return c.dim
|
|
}
|
|
|
|
// Get returns values at index as interface{}.
|
|
func (c *ColumnFloat16Vector) Get(idx int) (interface{}, error) {
|
|
if idx < 0 || idx >= c.Len() {
|
|
return nil, errors.New("index out of range")
|
|
}
|
|
return c.values[idx], nil
|
|
}
|
|
|
|
// AppendValue append value into column
|
|
func (c *ColumnFloat16Vector) AppendValue(i interface{}) error {
|
|
v, ok := i.([]byte)
|
|
if !ok {
|
|
return fmt.Errorf("invalid type, expected []byte, got %T", i)
|
|
}
|
|
c.values = append(c.values, v)
|
|
|
|
return nil
|
|
}
|
|
|
|
// Data returns column data
|
|
func (c *ColumnFloat16Vector) Data() [][]byte {
|
|
return c.values
|
|
}
|
|
|
|
// FieldData return column data mapped to schemapb.FieldData
|
|
func (c *ColumnFloat16Vector) FieldData() *schemapb.FieldData {
|
|
fd := &schemapb.FieldData{
|
|
Type: schemapb.DataType_Float16Vector,
|
|
FieldName: c.name,
|
|
}
|
|
|
|
data := make([]byte, 0, len(c.values)*c.dim*2)
|
|
|
|
for _, vector := range c.values {
|
|
data = append(data, vector...)
|
|
}
|
|
|
|
fd.Field = &schemapb.FieldData_Vectors{
|
|
Vectors: &schemapb.VectorField{
|
|
Dim: int64(c.dim),
|
|
|
|
Data: &schemapb.VectorField_Float16Vector{
|
|
Float16Vector: data,
|
|
},
|
|
},
|
|
}
|
|
return fd
|
|
}
|
|
|
|
// NewColumnFloat16Vector auto generated constructor
|
|
func NewColumnFloat16Vector(name string, dim int, values [][]byte) *ColumnFloat16Vector {
|
|
return &ColumnFloat16Vector{
|
|
name: name,
|
|
dim: dim,
|
|
values: values,
|
|
}
|
|
}
|
|
|
|
// ColumnBFloat16Vector generated columns type for BFloat16Vector
|
|
type ColumnBFloat16Vector struct {
|
|
ColumnBase
|
|
name string
|
|
dim int
|
|
values [][]byte
|
|
}
|
|
|
|
// Name returns column name
|
|
func (c *ColumnBFloat16Vector) Name() string {
|
|
return c.name
|
|
}
|
|
|
|
// Type returns column entity.FieldType
|
|
func (c *ColumnBFloat16Vector) Type() entity.FieldType {
|
|
return entity.FieldTypeBFloat16Vector
|
|
}
|
|
|
|
// Len returns column data length
|
|
func (c *ColumnBFloat16Vector) Len() int {
|
|
return len(c.values)
|
|
}
|
|
|
|
func (c *ColumnBFloat16Vector) Slice(start, end int) Column {
|
|
l := c.Len()
|
|
if start > l {
|
|
start = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
if end == -1 || end > l {
|
|
end = l
|
|
}
|
|
return &ColumnBFloat16Vector{
|
|
ColumnBase: c.ColumnBase,
|
|
name: c.name,
|
|
dim: c.dim,
|
|
values: c.values[start:end],
|
|
}
|
|
}
|
|
|
|
// Dim returns vector dimension
|
|
func (c *ColumnBFloat16Vector) Dim() int {
|
|
return c.dim
|
|
}
|
|
|
|
// Get returns values at index as interface{}.
|
|
func (c *ColumnBFloat16Vector) Get(idx int) (interface{}, error) {
|
|
if idx < 0 || idx >= c.Len() {
|
|
return nil, errors.New("index out of range")
|
|
}
|
|
return c.values[idx], nil
|
|
}
|
|
|
|
// AppendValue append value into column
|
|
func (c *ColumnBFloat16Vector) AppendValue(i interface{}) error {
|
|
v, ok := i.([]byte)
|
|
if !ok {
|
|
return fmt.Errorf("invalid type, expected []byte, got %T", i)
|
|
}
|
|
c.values = append(c.values, v)
|
|
|
|
return nil
|
|
}
|
|
|
|
// Data returns column data
|
|
func (c *ColumnBFloat16Vector) Data() [][]byte {
|
|
return c.values
|
|
}
|
|
|
|
// FieldData return column data mapped to schemapb.FieldData
|
|
func (c *ColumnBFloat16Vector) FieldData() *schemapb.FieldData {
|
|
fd := &schemapb.FieldData{
|
|
Type: schemapb.DataType_BFloat16Vector,
|
|
FieldName: c.name,
|
|
}
|
|
|
|
data := make([]byte, 0, len(c.values)*c.dim*2)
|
|
|
|
for _, vector := range c.values {
|
|
data = append(data, vector...)
|
|
}
|
|
|
|
fd.Field = &schemapb.FieldData_Vectors{
|
|
Vectors: &schemapb.VectorField{
|
|
Dim: int64(c.dim),
|
|
|
|
Data: &schemapb.VectorField_Bfloat16Vector{
|
|
Bfloat16Vector: data,
|
|
},
|
|
},
|
|
}
|
|
return fd
|
|
}
|
|
|
|
// NewColumnBFloat16Vector auto generated constructor
|
|
func NewColumnBFloat16Vector(name string, dim int, values [][]byte) *ColumnBFloat16Vector {
|
|
return &ColumnBFloat16Vector{
|
|
name: name,
|
|
dim: dim,
|
|
values: values,
|
|
}
|
|
}
|