Skip to content

Commit

Permalink
Feature/sorted (#77)
Browse files Browse the repository at this point in the history
* Fix param nil pointer

* Rename Param GetParams func to String to implement Stringer interface

* A scalar index: SORTED
  • Loading branch information
douglarek authored Dec 7, 2020
1 parent ea9dcc0 commit c846981
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
12 changes: 10 additions & 2 deletions milvus/ClientProxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,24 @@ func (client *Milvusclient) CreateCollection(ctx context.Context, mapping Mappin
var i int
for i = 0; i < fieldSize; i++ {
field := mapping.Fields[i]
ep := field.ExtraParams
if ep == nil {
ep = NewParams("")
}
grpcPair := make([]*pb.KeyValuePair, 1)
pair := pb.KeyValuePair{"params", field.ExtraParams.params,
pair := pb.KeyValuePair{"params", ep.params,
struct{}{}, nil, 0}
grpcPair[0] = &pair
grpcFields[i] = &pb.FieldParam{0, field.Name, pb.DataType(field.Type), nil,
grpcPair, struct{}{}, nil, 0,
}
}
grpcParam := make([]*pb.KeyValuePair, 1)
grpcParam[0] = &pb.KeyValuePair{"params", mapping.ExtraParams.params,
ep := mapping.ExtraParams
if ep == nil {
ep = NewParams("")
}
grpcParam[0] = &pb.KeyValuePair{"params", ep.params,
struct{}{}, nil, 0}
grpcMapping := pb.Mapping{nil, mapping.CollectionName, grpcFields, grpcParam,
struct{}{}, nil, 0,
Expand Down
3 changes: 3 additions & 0 deletions milvus/MilvusClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const (
RHNSWPQ IndexType = "RHNSW_PQ"
// RHNSWSQ8 RHNSW_SQ8
RHNSWSQ8 IndexType = "RHNSW_SQ8"

// SORTED a scalar index
SORTED IndexType = "SORTED"
)

// ConnectParam Parameters for connect
Expand Down
2 changes: 1 addition & 1 deletion milvus/Params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ func (p *Params) Set(key string, value interface{}) *Params {
return p
}

func (p *Params) GetParams() string {
func (p *Params) String() string {
return p.params
}
4 changes: 2 additions & 2 deletions milvus/Params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
)

func TestParams_Set(t *testing.T) {
s := NewParams("").Set("foo", "bar").GetParams()
s := NewParams("").Set("foo", "bar").String()
s1, _ := sjson.Set("", "foo", "bar")
if s != s1 {
t.Errorf("%s should be equal to %s", s, s1)
}

s = NewParams("").Set("foo", "bar").Set("foo.bar", "foo.bar").GetParams()
s = NewParams("").Set("foo", "bar").Set("foo.bar", "foo.bar").String()
s1, _ = sjson.Set("", "foo", "bar")
s1, _ = sjson.Set(s1, "foo.bar", "foo.bar")
if s != s1 {
Expand Down

0 comments on commit c846981

Please sign in to comment.