Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add probe command for query function #106

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions models/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ type CollectionHistory struct {
Dropped bool
}

func (c *Collection) GetPKField() (FieldSchema, bool) {
congqixia marked this conversation as resolved.
Show resolved Hide resolved
for _, field := range c.Schema.Fields {
if field.IsPrimaryKey {
return field, true
}
}
return FieldSchema{}, false
}

func (c *Collection) GetVectorField() (FieldSchema, bool) {
for _, field := range c.Schema.Fields {
if field.DataType == DataTypeBinaryVector || field.DataType == DataTypeFloatVector {
return field, true
}
}
return FieldSchema{}, false
}

// newCollectionFromBase fetchs common base information form proto objects
func newCollectionFromBase[collectionBase interface {
GetID() int64
Expand Down
18 changes: 18 additions & 0 deletions models/collection_schema.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package models

import (
"errors"
"strconv"
)

type CollectionSchema struct {
Name string
Fields []FieldSchema
Expand All @@ -15,6 +20,19 @@ type FieldSchema struct {
Properties map[string]string
}

func (fs *FieldSchema) GetDim() (int64, error) {
if fs.DataType != DataTypeFloatVector && fs.DataType != DataTypeBinaryVector {
return -1, errors.New("field is not vector")
}
raw, ok := fs.Properties["dim"]
if !ok {
return -1, errors.New("field not has dim property")
}

dim, err := strconv.ParseInt(raw, 10, 64)
return dim, err
}

func newSchemaFromBase[schemaBase interface {
GetName() string
}](schema schemaBase) CollectionSchema {
Expand Down
Loading