• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/third_party/vector_stores/qdrant.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
from typing import List
×
16

17
from evadb.third_party.vector_stores.types import (
×
18
    FeaturePayload,
19
    VectorIndexQuery,
20
    VectorIndexQueryResult,
21
    VectorStore,
22
)
23
from evadb.utils.generic_utils import try_to_import_qdrant_client
×
24

25
_qdrant_client_instance = None
×
26

27
required_params = ["index_db"]
×
28

29

30
def get_qdrant_client(path: str):
×
31
    global _qdrant_client_instance
32
    if _qdrant_client_instance is None:
×
33
        try_to_import_qdrant_client()
×
34
        import qdrant_client  # noqa: F401
×
35

36
        # creating a local mode client
37
        # modify to support server modes
38
        # https://github.com/qdrant/qdrant-client
39
        _qdrant_client_instance = qdrant_client.QdrantClient(path=path)
×
40
    return _qdrant_client_instance
×
41

42

43
class QdrantVectorStore(VectorStore):
×
44
    def __init__(self, index_name: str, index_db: str) -> None:
×
45
        self._client = get_qdrant_client(index_db)
×
46
        self._collection_name = index_name
×
47

48
    def create(self, vector_dim: int):
×
49
        from qdrant_client.models import Distance, VectorParams
×
50

51
        self._client.recreate_collection(
×
52
            collection_name=self._collection_name,
53
            vectors_config=VectorParams(size=vector_dim, distance=Distance.COSINE),
54
        )
55

56
    def add(self, payload: List[FeaturePayload]):
×
57
        from qdrant_client.models import Batch
×
58

59
        ids = [int(row.id) for row in payload]
×
60
        embeddings = [row.embedding.reshape(-1).tolist() for row in payload]
×
61
        self._client.upsert(
×
62
            collection_name=self._collection_name,
63
            points=Batch.construct(
64
                ids=ids,
65
                vectors=embeddings,
66
            ),
67
        )
68

69
    def delete(self) -> None:
×
70
        self._client.delete_collection(
×
71
            collection_name=self._collection_name,
72
        )
73

74
    def query(
×
75
        self,
76
        query: VectorIndexQuery,
77
    ) -> VectorIndexQueryResult:
78
        response = self._client.search(
×
79
            collection_name=self._collection_name,
80
            query_vector=query.embedding.reshape(-1).tolist(),
81
            limit=query.top_k,
82
        )
83

84
        distances, ids = [], []
×
85
        for point in response:
×
86
            distances.append(point.score)
×
87
            ids.append(int(point.id))
×
88

89
        return VectorIndexQueryResult(distances, ids)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc