github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/entity/columns_vector_gen.go (about)

     1  // Code generated by go generate; DO NOT EDIT
     2  // This file is generated by go generated
     3  package entity
     4  
     5  import (
     6  	"fmt"
     7  
     8  	schema "github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
     9  
    10  	"github.com/cockroachdb/errors"
    11  )
    12  
    13  
    14  // ColumnBinaryVector generated columns type for BinaryVector
    15  type ColumnBinaryVector struct {
    16  	ColumnBase
    17  	name   string
    18  	dim    int
    19  	values [][]byte
    20  }
    21  
    22  // Name returns column name
    23  func (c *ColumnBinaryVector) Name() string {
    24  	return c.name
    25  }
    26  
    27  // Type returns column FieldType
    28  func (c *ColumnBinaryVector) Type() FieldType {
    29  	return FieldTypeBinaryVector
    30  }
    31  
    32  // Len returns column data length
    33  func (c * ColumnBinaryVector) Len() int {
    34  	return len(c.values)
    35  }
    36  
    37  func (c *ColumnBinaryVector) Slice(start, end int) Column {
    38  	l := c.Len()
    39  	if start > l {
    40  		start = l
    41  	}
    42  	if end == -1 || end > l {
    43  		end = l
    44  	}
    45  	if end == -1 || end > l {
    46  		end = l
    47  	}
    48  	return &ColumnBinaryVector{
    49  		ColumnBase: c.ColumnBase,
    50  		name:       c.name,
    51  		dim:		c.dim,
    52  		values:     c.values[start:end],
    53  	}
    54  }
    55  
    56  // Dim returns vector dimension
    57  func (c *ColumnBinaryVector) Dim() int {
    58  	return c.dim
    59  }
    60  
    61  // Get returns values at index as interface{}.
    62  func (c *ColumnBinaryVector) Get(idx int) (interface{}, error) {
    63  	if idx < 0 || idx >= c.Len() {
    64  		return nil, errors.New("index out of range")
    65  	}
    66  	return c.values[idx], nil
    67  }
    68  
    69  // AppendValue append value into column
    70  func(c *ColumnBinaryVector) AppendValue(i interface{}) error {
    71  	v, ok := i.([]byte)
    72  	if !ok {
    73  		return fmt.Errorf("invalid type, expected []byte, got %T", i)
    74  	}
    75  	c.values = append(c.values, v)
    76  
    77  	return nil
    78  }
    79  
    80  // Data returns column data
    81  func (c *ColumnBinaryVector) Data() [][]byte {
    82  	return c.values
    83  }
    84  
    85  // FieldData return column data mapped to schema.FieldData
    86  func (c *ColumnBinaryVector) FieldData() *schema.FieldData {
    87  	fd := &schema.FieldData{
    88  		Type: schema.DataType_BinaryVector,
    89  		FieldName: c.name,
    90  	}
    91  
    92  	data := make([]byte, 0, len(c.values)* c.dim)
    93  
    94  	for _, vector := range c.values {
    95  		data = append(data, vector...)
    96  	}
    97  
    98  	fd.Field = &schema.FieldData_Vectors{
    99  		Vectors: &schema.VectorField{
   100  			Dim: int64(c.dim),
   101  			
   102  			Data: &schema.VectorField_BinaryVector{				
   103  				BinaryVector: data,
   104  			
   105  			},
   106  		},
   107  	}
   108  	return fd
   109  }
   110  
   111  // NewColumnBinaryVector auto generated constructor
   112  func NewColumnBinaryVector(name string, dim int, values [][]byte) *ColumnBinaryVector {
   113  	return &ColumnBinaryVector {
   114  		name:   name,
   115  		dim:    dim,
   116  		values: values,
   117  	}
   118  }
   119  
   120  // ColumnFloatVector generated columns type for FloatVector
   121  type ColumnFloatVector struct {
   122  	ColumnBase
   123  	name   string
   124  	dim    int
   125  	values [][]float32
   126  }
   127  
   128  // Name returns column name
   129  func (c *ColumnFloatVector) Name() string {
   130  	return c.name
   131  }
   132  
   133  // Type returns column FieldType
   134  func (c *ColumnFloatVector) Type() FieldType {
   135  	return FieldTypeFloatVector
   136  }
   137  
   138  // Len returns column data length
   139  func (c * ColumnFloatVector) Len() int {
   140  	return len(c.values)
   141  }
   142  
   143  // Dim returns vector dimension
   144  func (c *ColumnFloatVector) Dim() int {
   145  	return c.dim
   146  }
   147  
   148  // Get returns values at index as interface{}.
   149  func (c *ColumnFloatVector) Get(idx int) (interface{}, error) {
   150  	if idx < 0 || idx >= c.Len() {
   151  		return nil, errors.New("index out of range")
   152  	}
   153  	return c.values[idx], nil
   154  }
   155  
   156  func (c *ColumnFloatVector) Slice(start, end int) Column {
   157  	l := c.Len()
   158  	if start > l {
   159  		start = l
   160  	}
   161  	if end == -1 || end > l {
   162  		end = l
   163  	}
   164  	if end == -1 || end > l {
   165  		end = l
   166  	}
   167  	return &ColumnFloatVector{
   168  		ColumnBase: c.ColumnBase,
   169  		name:       c.name,
   170  		dim:		c.dim,
   171  		values:     c.values[start:end],
   172  	}
   173  }
   174  
   175  // AppendValue append value into column
   176  func(c *ColumnFloatVector) AppendValue(i interface{}) error {
   177  	v, ok := i.([]float32)
   178  	if !ok {
   179  		return fmt.Errorf("invalid type, expected []float32, got %T", i)
   180  	}
   181  	c.values = append(c.values, v)
   182  
   183  	return nil
   184  }
   185  
   186  // Data returns column data
   187  func (c *ColumnFloatVector) Data() [][]float32 {
   188  	return c.values
   189  }
   190  
   191  // FieldData return column data mapped to schema.FieldData
   192  func (c *ColumnFloatVector) FieldData() *schema.FieldData {
   193  	fd := &schema.FieldData{
   194  		Type: schema.DataType_FloatVector,
   195  		FieldName: c.name,
   196  	}
   197  
   198  	data := make([]float32, 0, len(c.values)* c.dim)
   199  
   200  	for _, vector := range c.values {
   201  		data = append(data, vector...)
   202  	}
   203  
   204  	fd.Field = &schema.FieldData_Vectors{
   205  		Vectors: &schema.VectorField{
   206  			Dim: int64(c.dim),
   207  			
   208  			Data: &schema.VectorField_FloatVector{
   209  				FloatVector: &schema.FloatArray{
   210  					Data: data,
   211  				},
   212  			
   213  			},
   214  		},
   215  	}
   216  	return fd
   217  }
   218  
   219  // NewColumnFloatVector auto generated constructor
   220  func NewColumnFloatVector(name string, dim int, values [][]float32) *ColumnFloatVector {
   221  	return &ColumnFloatVector {
   222  		name:   name,
   223  		dim:    dim,
   224  		values: values,
   225  	}
   226  }
   227  
   228  // ColumnFloat16Vector generated columns type for Float16Vector
   229  type ColumnFloat16Vector struct {
   230  	ColumnBase
   231  	name   string
   232  	dim    int
   233  	values [][]byte
   234  }
   235  
   236  // Name returns column name
   237  func (c *ColumnFloat16Vector) Name() string {
   238  	return c.name
   239  }
   240  
   241  // Type returns column FieldType
   242  func (c *ColumnFloat16Vector) Type() FieldType {
   243  	return FieldTypeFloat16Vector
   244  }
   245  
   246  // Len returns column data length
   247  func (c * ColumnFloat16Vector) Len() int {
   248  	return len(c.values)
   249  }
   250  
   251  func (c *ColumnFloat16Vector) Slice(start, end int) Column {
   252  	l := c.Len()
   253  	if start > l {
   254  		start = l
   255  	}
   256  	if end == -1 || end > l {
   257  		end = l
   258  	}
   259  	if end == -1 || end > l {
   260  		end = l
   261  	}
   262  	return &ColumnFloat16Vector{
   263  		ColumnBase: c.ColumnBase,
   264  		name:       c.name,
   265  		dim:		c.dim,
   266  		values:     c.values[start:end],
   267  	}
   268  }
   269  
   270  // Dim returns vector dimension
   271  func (c *ColumnFloat16Vector) Dim() int {
   272  	return c.dim
   273  }
   274  
   275  // Get returns values at index as interface{}.
   276  func (c *ColumnFloat16Vector) Get(idx int) (interface{}, error) {
   277  	if idx < 0 || idx >= c.Len() {
   278  		return nil, errors.New("index out of range")
   279  	}
   280  	return c.values[idx], nil
   281  }
   282  
   283  // AppendValue append value into column
   284  func(c *ColumnFloat16Vector) AppendValue(i interface{}) error {
   285  	v, ok := i.([]byte)
   286  	if !ok {
   287  		return fmt.Errorf("invalid type, expected []byte, got %T", i)
   288  	}
   289  	c.values = append(c.values, v)
   290  
   291  	return nil
   292  }
   293  
   294  // Data returns column data
   295  func (c *ColumnFloat16Vector) Data() [][]byte {
   296  	return c.values
   297  }
   298  
   299  // FieldData return column data mapped to schema.FieldData
   300  func (c *ColumnFloat16Vector) FieldData() *schema.FieldData {
   301  	fd := &schema.FieldData{
   302  		Type: schema.DataType_Float16Vector,
   303  		FieldName: c.name,
   304  	}
   305  
   306  	data := make([]byte, 0, len(c.values)* c.dim *2)
   307  
   308  	for _, vector := range c.values {
   309  		data = append(data, vector...)
   310  	}
   311  
   312  	fd.Field = &schema.FieldData_Vectors{
   313  		Vectors: &schema.VectorField{
   314  			Dim: int64(c.dim),
   315  			
   316  			Data: &schema.VectorField_Float16Vector{				
   317  				Float16Vector: data,
   318  			
   319  			},
   320  		},
   321  	}
   322  	return fd
   323  }
   324  
   325  // NewColumnFloat16Vector auto generated constructor
   326  func NewColumnFloat16Vector(name string, dim int, values [][]byte) *ColumnFloat16Vector {
   327  	return &ColumnFloat16Vector {
   328  		name:   name,
   329  		dim:    dim,
   330  		values: values,
   331  	}
   332  }
   333  
   334  // ColumnBFloat16Vector generated columns type for BFloat16Vector
   335  type ColumnBFloat16Vector struct {
   336  	ColumnBase
   337  	name   string
   338  	dim    int
   339  	values [][]byte
   340  }
   341  
   342  // Name returns column name
   343  func (c *ColumnBFloat16Vector) Name() string {
   344  	return c.name
   345  }
   346  
   347  // Type returns column FieldType
   348  func (c *ColumnBFloat16Vector) Type() FieldType {
   349  	return FieldTypeBFloat16Vector
   350  }
   351  
   352  // Len returns column data length
   353  func (c * ColumnBFloat16Vector) Len() int {
   354  	return len(c.values)
   355  }
   356  
   357  func (c *ColumnBFloat16Vector) Slice(start, end int) Column {
   358  	l := c.Len()
   359  	if start > l {
   360  		start = l
   361  	}
   362  	if end == -1 || end > l {
   363  		end = l
   364  	}
   365  	if end == -1 || end > l {
   366  		end = l
   367  	}
   368  	return &ColumnBFloat16Vector{
   369  		ColumnBase: c.ColumnBase,
   370  		name:       c.name,
   371  		dim:		c.dim,
   372  		values:     c.values[start:end],
   373  	}
   374  }
   375  
   376  // Dim returns vector dimension
   377  func (c *ColumnBFloat16Vector) Dim() int {
   378  	return c.dim
   379  }
   380  
   381  // Get returns values at index as interface{}.
   382  func (c *ColumnBFloat16Vector) Get(idx int) (interface{}, error) {
   383  	if idx < 0 || idx >= c.Len() {
   384  		return nil, errors.New("index out of range")
   385  	}
   386  	return c.values[idx], nil
   387  }
   388  
   389  // AppendValue append value into column
   390  func(c *ColumnBFloat16Vector) AppendValue(i interface{}) error {
   391  	v, ok := i.([]byte)
   392  	if !ok {
   393  		return fmt.Errorf("invalid type, expected []byte, got %T", i)
   394  	}
   395  	c.values = append(c.values, v)
   396  
   397  	return nil
   398  }
   399  
   400  // Data returns column data
   401  func (c *ColumnBFloat16Vector) Data() [][]byte {
   402  	return c.values
   403  }
   404  
   405  // FieldData return column data mapped to schema.FieldData
   406  func (c *ColumnBFloat16Vector) FieldData() *schema.FieldData {
   407  	fd := &schema.FieldData{
   408  		Type: schema.DataType_BFloat16Vector,
   409  		FieldName: c.name,
   410  	}
   411  
   412  	data := make([]byte, 0, len(c.values)* c.dim*2)
   413  
   414  	for _, vector := range c.values {
   415  		data = append(data, vector...)
   416  	}
   417  
   418  	fd.Field = &schema.FieldData_Vectors{
   419  		Vectors: &schema.VectorField{
   420  			Dim: int64(c.dim),
   421  			
   422  			Data: &schema.VectorField_Bfloat16Vector{
   423  				Bfloat16Vector: data,
   424  			
   425  			},
   426  		},
   427  	}
   428  	return fd
   429  }
   430  
   431  // NewColumnBFloat16Vector auto generated constructor
   432  func NewColumnBFloat16Vector(name string, dim int, values [][]byte) *ColumnBFloat16Vector {
   433  	return &ColumnBFloat16Vector {
   434  		name:   name,
   435  		dim:    dim,
   436  		values: values,
   437  	}
   438  }
   439