Skip to content

Commit

Permalink
enhance: add Slice func for go milvusclient column (#33836)
Browse files Browse the repository at this point in the history
issue: #33419

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
  • Loading branch information
ThreadDao committed Jun 17, 2024
1 parent f993b29 commit 2da289c
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 0 deletions.
15 changes: 15 additions & 0 deletions client/column/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ func (c *ColumnVarCharArray) Len() int {
return len(c.values)
}

func (c *ColumnVarCharArray) Slice(start, end int) Column {
l := c.Len()
if start > l {
start = l
}
if end == -1 || end > l {
end = l
}
return &ColumnVarCharArray{
ColumnBase: c.ColumnBase,
name: c.name,
values: c.values[start:end],
}
}

// Get returns value at index as interface{}.
func (c *ColumnVarCharArray) Get(idx int) (interface{}, error) {
var r []string // use default value
Expand Down
108 changes: 108 additions & 0 deletions client/column/array_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/column/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Column interface {
Name() string
Type() entity.FieldType
Len() int
Slice(int, int) Column
FieldData() *schemapb.FieldData
AppendValue(interface{}) error
Get(int) (interface{}, error)
Expand Down
15 changes: 15 additions & 0 deletions client/column/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ func (c *ColumnJSONBytes) Len() int {
return len(c.values)
}

func (c *ColumnJSONBytes) Slice(start, end int) Column {
l := c.Len()
if start > l {
start = l
}
if end == -1 || end > l {
end = l
}
return &ColumnJSONBytes{
ColumnBase: c.ColumnBase,
name: c.name,
values: c.values[start:end],
}
}

// Get returns value at index as interface{}.
func (c *ColumnJSONBytes) Get(idx int) (interface{}, error) {
if idx < 0 || idx > c.Len() {
Expand Down
120 changes: 120 additions & 0 deletions client/column/scalar_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2da289c

Please sign in to comment.