mirror of https://github.com/milvus-io/milvus.git
Add interface for QueryShardService and QueryShard (#16309)
Signed-off-by: Letian Jiang <letian.jiang@zilliz.com>pull/16315/head
parent
0d54697d42
commit
ad9a2217ae
|
@ -0,0 +1,55 @@
|
|||
// 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 querynode
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
||||
"github.com/milvus-io/milvus/internal/proto/querypb"
|
||||
)
|
||||
|
||||
type queryShard struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
collectionID UniqueID
|
||||
channel Channel
|
||||
}
|
||||
|
||||
func newQueryShard(
|
||||
ctx context.Context,
|
||||
cancel context.CancelFunc,
|
||||
collectionID UniqueID,
|
||||
channel Channel,
|
||||
) *queryShard {
|
||||
qs := &queryShard{
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
collectionID: collectionID,
|
||||
channel: channel,
|
||||
}
|
||||
return qs
|
||||
}
|
||||
|
||||
func (q *queryShard) search(ctx context.Context, req *querypb.SearchRequest) (*milvuspb.SearchResults, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (q *queryShard) query(ctx context.Context, req *querypb.QueryRequest) (*milvuspb.QueryResults, error) {
|
||||
return nil, nil
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
// 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 querynode
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type queryShardService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
queryShardsMu sync.Mutex // guards queryShards
|
||||
queryShards map[Channel]*queryShard // Virtual Channel -> *queryShard
|
||||
}
|
||||
|
||||
func newQueryShardService(ctx context.Context) *queryShardService {
|
||||
queryShardServiceCtx, queryShardServiceCancel := context.WithCancel(ctx)
|
||||
qss := &queryShardService{
|
||||
ctx: queryShardServiceCtx,
|
||||
cancel: queryShardServiceCancel,
|
||||
queryShards: make(map[Channel]*queryShard),
|
||||
}
|
||||
return qss
|
||||
}
|
||||
|
||||
func (q *queryShardService) addQueryShard(collectionID UniqueID, channel Channel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *queryShardService) removeQueryShard(collectionID UniqueID, channel Channel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *queryShardService) hasQueryShard(collectionID UniqueID, channel Channel) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (q *queryShardService) getQueryShard(collectionID UniqueID, channel Channel) (*queryShard, error) {
|
||||
return nil, nil
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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 querynode
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryShardService(t *testing.T) {
|
||||
qss := newQueryShardService(context.Background())
|
||||
err := qss.addQueryShard(0, "vchan1")
|
||||
assert.NoError(t, err)
|
||||
found := qss.hasQueryShard(0, "vchan2")
|
||||
assert.Equal(t, false, found)
|
||||
_, err = qss.getQueryShard(0, "vchan1")
|
||||
assert.NoError(t, err)
|
||||
err = qss.removeQueryShard(0, "vchan2")
|
||||
assert.Equal(t, nil, err)
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// 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 querynode
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/proto/querypb"
|
||||
)
|
||||
|
||||
func TestQueryShard_Search(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
qs := newQueryShard(ctx, cancel, 0, "vchan1")
|
||||
_, err := qs.search(context.Background(), &querypb.SearchRequest{})
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestQueryShard_Query(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
qs := newQueryShard(ctx, cancel, 0, "vchan1")
|
||||
_, err := qs.query(context.Background(), &querypb.QueryRequest{})
|
||||
assert.NoError(t, err)
|
||||
}
|
Loading…
Reference in New Issue