forked from milvus-io/milvus
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue: milvus-io#15604 Signed-off-by: Yuchen Gao <yuchen.gao@zilliz.com>
- Loading branch information
1 parent
1c4b949
commit 5b0440d
Showing
14 changed files
with
1,033 additions
and
320 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
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,152 @@ | ||
// Licensed to the LF AI & Data foundation under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package kv | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/milvus-io/milvus/internal/log" | ||
clientv3 "go.etcd.io/etcd/client/v3" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type mockBaseKV struct { | ||
InMemKv map[string]string | ||
} | ||
|
||
func (m *mockBaseKV) Load(key string) (string, error) { | ||
if val, ok := m.InMemKv[key]; ok { | ||
return val, nil | ||
} | ||
return "", nil | ||
} | ||
|
||
func (m *mockBaseKV) MultiLoad(keys []string) ([]string, error) { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) LoadWithPrefix(key string) ([]string, []string, error) { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) Save(key string, value string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) MultiSave(kvs map[string]string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) Remove(key string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) MultiRemove(keys []string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) RemoveWithPrefix(key string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockBaseKV) Close() { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
type mockTxnKV struct { | ||
mockBaseKV | ||
} | ||
|
||
func (m *mockTxnKV) MultiSaveAndRemove(saves map[string]string, removals []string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockTxnKV) MultiRemoveWithPrefix(keys []string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *mockTxnKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
type MockMetaKV struct { | ||
mockTxnKV | ||
} | ||
|
||
func (m *MockMetaKV) GetPath(key string) string { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) LoadWithPrefix(prefix string) ([]string, []string, error) { | ||
keys := make([]string, 0, len(m.InMemKv)) | ||
values := make([]string, 0, len(m.InMemKv)) | ||
for k, v := range m.InMemKv { | ||
if strings.HasPrefix(k, prefix) { | ||
keys = append(keys, k) | ||
values = append(values, v) | ||
} | ||
} | ||
return keys, values, nil | ||
} | ||
|
||
func (m *MockMetaKV) LoadWithPrefix2(key string) ([]string, []string, []int64, error) { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) LoadWithRevision(key string) ([]string, []string, int64, error) { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) Watch(key string) clientv3.WatchChan { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) WatchWithPrefix(key string) clientv3.WatchChan { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) WatchWithRevision(key string, revision int64) clientv3.WatchChan { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) SaveWithLease(key, value string, id clientv3.LeaseID) error { | ||
m.InMemKv[key] = value | ||
log.Debug("Doing SaveWithLease", zap.String("key", key)) | ||
return nil | ||
} | ||
|
||
func (m *MockMetaKV) SaveWithIgnoreLease(key, value string) error { | ||
m.InMemKv[key] = value | ||
log.Debug("Doing SaveWithIgnoreLease", zap.String("key", key)) | ||
return nil | ||
} | ||
|
||
func (m *MockMetaKV) Grant(ttl int64) (id clientv3.LeaseID, err error) { | ||
return 1, nil | ||
} | ||
|
||
func (m *MockMetaKV) KeepAlive(id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error) { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) CompareValueAndSwap(key, value, target string, opts ...clientv3.OpOption) error { | ||
panic("not implemented") // TODO: Implement | ||
} | ||
|
||
func (m *MockMetaKV) CompareVersionAndSwap(key string, version int64, target string, opts ...clientv3.OpOption) error { | ||
panic("not implemented") // TODO: Implement | ||
} |
Oops, something went wrong.