Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docarray/index/backends/hnswlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,15 @@ def num_docs(self) -> int:
Get the number of documents.
"""
if self._num_docs == 0:
self._num_docs = self._get_num_docs_sqlite()
self._num_docs = self._get_num_docs_hnsw()
return self._num_docs

def _get_num_docs_hnsw(self) -> int:
"""
Get the number of documents using the HNSW method.
"""
# Access your HNSW index here and retrieve the count of documents
hnsw_num_docs = self.hnsw_index.get_document_count()
Comment thread
shobhit9957 marked this conversation as resolved.
return hnsw_num_docs
###############################################
# Helpers #
###############################################
Expand Down