/
columns_int32.go
executable file
·76 lines (65 loc) · 1.64 KB
/
columns_int32.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Code generated by go generate; DO NOT EDIT
// This file is generated by go generate at 2021-07-19 17:30:03.688864552 +0800 CST m=+0.002944243
package entity
import (
"errors"
"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/schema"
)
// ColumnInt32 generated columns type for Int32
type ColumnInt32 struct {
name string
values []int32
}
// Name returns column name
func (c *ColumnInt32) Name() string {
return c.name
}
// Type returns column FieldType
func (c *ColumnInt32) Type() FieldType {
return FieldTypeInt32
}
// Len returns column values length
func (c *ColumnInt32) Len() int {
return len(c.values)
}
// FieldData return column data mapped to schema.FieldData
func (c *ColumnInt32) FieldData() *schema.FieldData {
fd := &schema.FieldData{
Type: schema.DataType_Int32,
FieldName: c.name,
}
data := make([]int32, 0, c.Len())
for i := 0 ;i < c.Len(); i++ {
data = append(data, int32(c.values[i]))
}
fd.Field = &schema.FieldData_Scalars{
Scalars: &schema.ScalarField{
Data: &schema.ScalarField_IntData{
IntData: &schema.IntArray{
Data: data,
},
},
},
}
return fd
}
// ValueByIdx returns value of the provided index
// error occurs when index out of range
func (c *ColumnInt32) ValueByIdx(idx int) (int32, error) {
var r int32 // use default value
if idx < 0 || idx >= c.Len() {
return r, errors.New("index out of range")
}
return c.values[idx], nil
}
// Data returns column data
func (c *ColumnInt32) Data() []int32 {
return c.values
}
// NewColumnInt32 auto generated constructor
func NewColumnInt32(name string, values []int32) *ColumnInt32 {
return &ColumnInt32 {
name: name,
values: values,
}
}