2021-01-22 19:43:27 +08:00
|
|
|
package dataservice
|
|
|
|
|
|
|
|
import (
|
2021-02-26 17:44:24 +08:00
|
|
|
"context"
|
2021-01-22 19:43:27 +08:00
|
|
|
"sync/atomic"
|
|
|
|
"time"
|
|
|
|
|
2021-02-02 18:53:10 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/datapb"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
|
|
|
|
|
2021-01-22 19:43:27 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
|
|
|
|
|
|
|
|
memkv "github.com/zilliztech/milvus-distributed/internal/kv/mem"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/tsoutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newMemoryMeta(allocator allocator) (*meta, error) {
|
|
|
|
memoryKV := memkv.NewMemoryKV()
|
2021-01-25 15:17:17 +08:00
|
|
|
return newMeta(memoryKV)
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type MockAllocator struct {
|
|
|
|
cnt int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockAllocator) allocTimestamp() (Timestamp, error) {
|
|
|
|
val := atomic.AddInt64(&m.cnt, 1)
|
|
|
|
phy := time.Now().UnixNano() / int64(time.Millisecond)
|
|
|
|
ts := tsoutil.ComposeTS(phy, val)
|
|
|
|
return ts, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockAllocator) allocID() (UniqueID, error) {
|
|
|
|
val := atomic.AddInt64(&m.cnt, 1)
|
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func newMockAllocator() *MockAllocator {
|
|
|
|
return &MockAllocator{}
|
|
|
|
}
|
|
|
|
|
2021-01-23 14:41:29 +08:00
|
|
|
func newTestSchema() *schemapb.CollectionSchema {
|
2021-01-22 19:43:27 +08:00
|
|
|
return &schemapb.CollectionSchema{
|
|
|
|
Name: "test",
|
|
|
|
Description: "schema for test used",
|
|
|
|
AutoID: false,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
{FieldID: 1, Name: "field1", IsPrimaryKey: false, Description: "field no.1", DataType: schemapb.DataType_STRING},
|
|
|
|
{FieldID: 2, Name: "field2", IsPrimaryKey: false, Description: "field no.2", DataType: schemapb.DataType_VECTOR_FLOAT},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-02-02 18:53:10 +08:00
|
|
|
|
|
|
|
type mockDataNodeClient struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func newMockDataNodeClient() *mockDataNodeClient {
|
|
|
|
return &mockDataNodeClient{}
|
|
|
|
}
|
|
|
|
|
2021-02-26 17:44:24 +08:00
|
|
|
func (c *mockDataNodeClient) WatchDmChannels(ctx context.Context, in *datapb.WatchDmChannelRequest) (*commonpb.Status, error) {
|
2021-02-02 18:53:10 +08:00
|
|
|
return &commonpb.Status{ErrorCode: commonpb.ErrorCode_SUCCESS}, nil
|
|
|
|
}
|
|
|
|
|
2021-02-26 17:44:24 +08:00
|
|
|
func (c *mockDataNodeClient) GetComponentStates(ctx context.Context, empty *commonpb.Empty) (*internalpb2.ComponentStates, error) {
|
2021-02-02 18:53:10 +08:00
|
|
|
// todo
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2021-02-26 17:44:24 +08:00
|
|
|
func (c *mockDataNodeClient) FlushSegments(ctx context.Context, in *datapb.FlushSegRequest) (*commonpb.Status, error) {
|
2021-02-02 18:53:10 +08:00
|
|
|
return &commonpb.Status{ErrorCode: commonpb.ErrorCode_SUCCESS}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockDataNodeClient) Stop() error {
|
|
|
|
return nil
|
|
|
|
}
|