Skip to content

solved the good first issue in the hnswlib.py file#1764

Closed
shobhit9957 wants to merge 2 commits into
docarray:mainfrom
shobhit9957:main
Closed

solved the good first issue in the hnswlib.py file#1764
shobhit9957 wants to merge 2 commits into
docarray:mainfrom
shobhit9957:main

Conversation

@shobhit9957

Copy link
Copy Markdown

Hey Joan, I've done it, according to the issue. I hope it was correct! Thanks for helping Joan.

@JoanFM

JoanFM commented Aug 24, 2023

Copy link
Copy Markdown
Member

Hey @shobhit9957,

Sorry for the missunderstanding, this is correct, but you will need to implement the private method.

@shobhit9957

Copy link
Copy Markdown
Author

Can you please elaborate on that meaning private method..., how can I do that in private method

@shobhit9957

shobhit9957 commented Aug 24, 2023

Copy link
Copy Markdown
Author

hey joan, once check this :

def num_docs(self) -> int:
    """
    Get the number of documents.
    """
    if self._num_docs == 0:
        # Replace the old method with the new one
        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.
    This method should return the count of documents using the new technique.
    """
    # Implement your logic here to get the count using the HNSW method
    # For example, you might access some data or perform calculations
    # that help you quickly determine the number of documents.
    # Then return the count.
    return calculated_num_docs

is this correct?

@JoanFM

JoanFM commented Aug 24, 2023

Copy link
Copy Markdown
Member

hey joan, once check this :

def num_docs(self) -> int:
    """
    Get the number of documents.
    """
    if self._num_docs == 0:
        # Replace the old method with the new one
        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.
    This method should return the count of documents using the new technique.
    """
    # Implement your logic here to get the count using the HNSW method
    # For example, you might access some data or perform calculations
    # that help you quickly determine the number of documents.
    # Then return the count.
    return calculated_num_docs

is this correct?

Yes, and this computation shpuld come from inside the hnsw indices

Comment thread docarray/index/backends/hnswlib.py
shobhit9957 added a commit to shobhit9957/docarray that referenced this pull request Aug 25, 2023
Signed-off-by: Shobhit Kumar <116124866+shobhit9957@users.noreply.github.com>
shobhit9957 added a commit to shobhit9957/docarray that referenced this pull request Aug 25, 2023
Signed-off-by: Shobhit Kumar <116124866+shobhit9957@users.noreply.github.com>
shobhit9957 added a commit to shobhit9957/docarray that referenced this pull request Aug 25, 2023
Signed-off-by: Shobhit Kumar <116124866+shobhit9957@users.noreply.github.com>
@JoanFM JoanFM closed this Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants