Skip to content

Commit

Permalink
fix: Set Slice start to Len if out-of-bound (#751)
Browse files Browse the repository at this point in the history
Fix slice may panic with out of bound error when last batch is not
sufficent for batch size in query iterator

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia authored May 30, 2024
1 parent 979f77e commit f477955
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions entity/columns_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (c *ColumnVarCharArray) Len() int {
}

func (c *ColumnVarCharArray) Slice(start, end int) Column {
if start > c.Len() {
start = c.Len()
}
if end == -1 || end > c.Len() {
end = c.Len()
}
Expand Down
21 changes: 21 additions & 0 deletions entity/columns_array_gen.go

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

3 changes: 3 additions & 0 deletions entity/columns_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func (c *ColumnJSONBytes) Len() int {
}

func (c *ColumnJSONBytes) Slice(start, end int) Column {
if start > c.Len() {
start = c.Len()
}
if end == -1 || end > c.Len() {
end = c.Len()
}
Expand Down
24 changes: 24 additions & 0 deletions entity/columns_scalar_gen.go

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

3 changes: 3 additions & 0 deletions entity/columns_sparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ func (c *ColumnSparseFloatVector) Len() int {
}

func (c *ColumnSparseFloatVector) Slice(start, end int) Column {
if start > c.Len() {
start = c.Len()
}
if end == -1 || end > c.Len() {
end = c.Len()
}
Expand Down
3 changes: 3 additions & 0 deletions entity/columns_varchar.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func (c *ColumnVarChar) GetAsString(idx int) (string, error) {
}

func (c *ColumnVarChar) Slice(start, end int) Column {
if start > c.Len() {
start = c.Len()
}
if end == -1 || end > c.Len() {
end = c.Len()
}
Expand Down
12 changes: 12 additions & 0 deletions entity/columns_vector_gen.go

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

0 comments on commit f477955

Please sign in to comment.