-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/add-index-interface' into 'main' (merge request !59)
feat/add-index-interface feat: add new index/add interface
- Loading branch information
Showing
16 changed files
with
940 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# Changelog | ||
|
||
## v1.4.4 | ||
* 新增/index/add接口实现 | ||
|
||
## v1.0.0 | ||
|
||
### DatabaseInterface | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package tcvectordb | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/tencent/vectordatabase-sdk-go/tcvectordb/api" | ||
"github.com/tencent/vectordatabase-sdk-go/tcvectordb/api/index" | ||
) | ||
|
||
var _ FlatIndexInterface = &implementerFlatIndex{} | ||
|
||
type FlatIndexInterface interface { | ||
SdkClient | ||
RebuildIndex(ctx context.Context, databaseName, collectionName string, params ...*RebuildIndexParams) (result *RebuildIndexResult, err error) | ||
AddIndex(ctx context.Context, databaseName, collectionName string, params ...*AddIndexParams) (err error) | ||
} | ||
|
||
type implementerFlatIndex struct { | ||
SdkClient | ||
} | ||
|
||
type RebuildIndexParams struct { | ||
DropBeforeRebuild bool | ||
Throttle int | ||
} | ||
|
||
type AddIndexParams struct { | ||
FilterIndexs []FilterIndex | ||
BuildExistedData *bool | ||
} | ||
|
||
func (i *implementerFlatIndex) RebuildIndex(ctx context.Context, databaseName, collectionName string, params ...*RebuildIndexParams) (*RebuildIndexResult, error) { | ||
req := new(index.RebuildReq) | ||
req.Database = databaseName | ||
req.Collection = collectionName | ||
|
||
if len(params) != 0 && params[0] != nil { | ||
param := params[0] | ||
req.DropBeforeRebuild = param.DropBeforeRebuild | ||
req.Throttle = int32(param.Throttle) | ||
} | ||
|
||
res := new(index.RebuildRes) | ||
err := i.Request(ctx, req, &res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result := new(RebuildIndexResult) | ||
result.TaskIds = res.TaskIds | ||
return result, nil | ||
} | ||
|
||
func (i *implementerFlatIndex) AddIndex(ctx context.Context, databaseName, collectionName string, params ...*AddIndexParams) error { | ||
req := new(index.AddReq) | ||
req.Database = databaseName | ||
req.Collection = collectionName | ||
if len(params) != 0 && params[0] != nil { | ||
param := params[0] | ||
for _, index := range param.FilterIndexs { | ||
req.Indexes = append(req.Indexes, &api.IndexColumn{ | ||
FieldName: index.FieldName, | ||
FieldType: string(index.FieldType), | ||
IndexType: string(index.IndexType), | ||
}) | ||
} | ||
req.BuildExistedData = param.BuildExistedData | ||
} | ||
|
||
res := new(index.AddRes) | ||
err := i.Request(ctx, req, res) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.