Skip to content

Commit

Permalink
Rename composite_query to query_namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Oct 21, 2024
1 parent fa1cbe5 commit 0c9ecb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pinecone/grpc/index_grpc_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
parse_sparse_values_arg,
)
from .vector_factory_grpc import VectorFactoryGRPC
from .query_results_aggregator import QueryResultsAggregator, CompositeQueryResults
from .query_results_aggregator import QueryResultsAggregator, QueryNamespacesResults


class GRPCIndexAsyncio(GRPCIndexBase):
Expand Down Expand Up @@ -256,7 +256,7 @@ async def query(
)
return parse_query_response(json_response, _check_type=False)

async def composite_query(
async def query_namespaces(
self,
vector: List[float],
namespaces: List[str],
Expand All @@ -269,7 +269,7 @@ async def composite_query(
max_concurrent_requests: Optional[int] = None,
semaphore: Optional[asyncio.Semaphore] = None,
**kwargs,
) -> CompositeQueryResults:
) -> QueryNamespacesResults:
aggregator_lock = asyncio.Lock()
semaphore = self._get_semaphore(max_concurrent_requests, semaphore)

Expand Down
10 changes: 5 additions & 5 deletions pinecone/grpc/query_results_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def _truncate(self, obj, max_items=2):


@dataclass
class CompositeQueryResults:
class QueryNamespacesResults:
usage: Usage
matches: List[ScoredVectorWithNamespace]

def __getitem__(self, key):
if hasattr(self, key):
return getattr(self, key)
else:
raise KeyError(f"'{key}' not found in CompositeQueryResults")
raise KeyError(f"'{key}' not found in QueryNamespacesResults")

def __repr__(self):
return json.dumps(
Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self, top_k: int):
self.insertion_counter = 0
self.is_dotproduct = None
self.read = False
self.final_results: Optional[CompositeQueryResults] = None
self.final_results: Optional[QueryNamespacesResults] = None

def _is_dotproduct_index(self, matches):
# The interpretation of the score depends on the similar metric used.
Expand Down Expand Up @@ -160,7 +160,7 @@ def add_results(self, results: Dict[str, Any]):
else:
self._process_matches(matches, ns, self._non_dotproduct_heap_item)

def get_results(self) -> CompositeQueryResults:
def get_results(self) -> QueryNamespacesResults:
if self.read:
if self.final_results is not None:
return self.final_results
Expand All @@ -169,7 +169,7 @@ def get_results(self) -> CompositeQueryResults:
raise ValueError("Results have already been read. Cannot get results again.")
self.read = True

self.final_results = CompositeQueryResults(
self.final_results = QueryNamespacesResults(
usage=Usage(read_units=self.usage_read_units),
matches=[
ScoredVectorWithNamespace(heapq.heappop(self.heap)) for _ in range(len(self.heap))
Expand Down

0 comments on commit 0c9ecb7

Please sign in to comment.