hti-index


Namehti-index JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/diomandeee/hti_index
SummaryPython package for implementing a HasH Table Index
upload_time2023-04-21 06:32:17
maintainer
docs_urlNone
authorMohamed Diomande
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Hash Table Index (HTI)

The Hash Table Index (HTI) is a data structure used to efficiently store and retrieve data based on its content hash. The HTI consists of nodes that can be either composite or leaf nodes. Composite nodes are used to group other nodes together and form a tree structure. Leaf nodes store actual data and are at the bottom of the tree. The content hash is used as the key to look up data in the tree.

## NodeComposite

NodeComposite is a class that represents a composite node in the HTI. A composite node can have child nodes that are either composite or leaf nodes. The NodeComposite class uses NumPy arrays to store child nodes and their content hashes.

One of the main features of the NodeComposite class is the lookup_table attribute. This attribute is a class attribute that stores nodes by their hashes. This allows for quick lookups of nodes by their hashes, which is useful when traversing the tree.

## Weak Reference
In the NodeComposite class, we can optimize the lookup_table attribute by using weak references. A weak reference is a reference to an object that does not prevent the object from being garbage collected. In the case of NodeComposite, using weak references for the lookup_table attribute allows for the garbage collection of nodes that are no longer used.

To use weak references in the NodeComposite class, we can use the weakref module. The WeakValueDictionary class from the weakref module can be used to create a dictionary that stores weak references to objects. This allows us to store nodes in the lookup_table attribute as weak references. When a node is no longer used in the tree, it can be garbage collected, and the corresponding weak reference in the lookup_table attribute will be automatically removed.

## NodeComposite Methods

The NodeComposite class has several methods that are used to add, remove, and retrieve child nodes. The add_child method is used to add a child node to the composite node. The remove_child method is used to remove a child node from the composite node. The get_child_by_hash method is used to retrieve a child node by its content hash. The get_parent_by_hash method is used to retrieve the parent node of a child node by its content hash. The get_node_by_hash method is used to retrieve a node by its content hash. The get_child_by_index method is used to retrieve a child node by its index. The clear_children method is used to remove all child nodes from the composite node.

## HTIIndex

The HTIIndex class is a wrapper class that provides an interface for the HTI. The HTIIndex class uses a NumPy array to store buckets of nodes. The HTIIndex class uses the content hash of the data to determine which bucket to store the data in. The HTIIndex class also uses a dictionary to store nodes by their content hashes. This allows for quick lookups of nodes by their content hashes.     

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/diomandeee/hti_index",
    "name": "hti-index",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mohamed Diomande",
    "author_email": "gdiomande7907@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c6/91/6537b7d5dec18c36cac8682eea8d834ccc72137fa6cc9ff51326d74dcf53/hti_index-0.1.2.tar.gz",
    "platform": null,
    "description": "\n# Hash Table Index (HTI)\n\nThe Hash Table Index (HTI) is a data structure used to efficiently store and retrieve data based on its content hash. The HTI consists of nodes that can be either composite or leaf nodes. Composite nodes are used to group other nodes together and form a tree structure. Leaf nodes store actual data and are at the bottom of the tree. The content hash is used as the key to look up data in the tree.\n\n## NodeComposite\n\nNodeComposite is a class that represents a composite node in the HTI. A composite node can have child nodes that are either composite or leaf nodes. The NodeComposite class uses NumPy arrays to store child nodes and their content hashes.\n\nOne of the main features of the NodeComposite class is the lookup_table attribute. This attribute is a class attribute that stores nodes by their hashes. This allows for quick lookups of nodes by their hashes, which is useful when traversing the tree.\n\n## Weak Reference\nIn the NodeComposite class, we can optimize the lookup_table attribute by using weak references. A weak reference is a reference to an object that does not prevent the object from being garbage collected. In the case of NodeComposite, using weak references for the lookup_table attribute allows for the garbage collection of nodes that are no longer used.\n\nTo use weak references in the NodeComposite class, we can use the weakref module. The WeakValueDictionary class from the weakref module can be used to create a dictionary that stores weak references to objects. This allows us to store nodes in the lookup_table attribute as weak references. When a node is no longer used in the tree, it can be garbage collected, and the corresponding weak reference in the lookup_table attribute will be automatically removed.\n\n## NodeComposite Methods\n\nThe NodeComposite class has several methods that are used to add, remove, and retrieve child nodes. The add_child method is used to add a child node to the composite node. The remove_child method is used to remove a child node from the composite node. The get_child_by_hash method is used to retrieve a child node by its content hash. The get_parent_by_hash method is used to retrieve the parent node of a child node by its content hash. The get_node_by_hash method is used to retrieve a node by its content hash. The get_child_by_index method is used to retrieve a child node by its index. The clear_children method is used to remove all child nodes from the composite node.\n\n## HTIIndex\n\nThe HTIIndex class is a wrapper class that provides an interface for the HTI. The HTIIndex class uses a NumPy array to store buckets of nodes. The HTIIndex class uses the content hash of the data to determine which bucket to store the data in. The HTIIndex class also uses a dictionary to store nodes by their content hashes. This allows for quick lookups of nodes by their content hashes.     \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package for implementing a HasH Table Index",
    "version": "0.1.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c0ecba41e4ccde1c314e00c42c7da94d9794332c159d9f545414b4c6a1ce50c",
                "md5": "1bfb01c4711fbbb773a7cc10bb06e3bf",
                "sha256": "b11975a680c4b1f67aaa3706903191824e8bf00ffe34f54e3ac6d263a4058ad3"
            },
            "downloads": -1,
            "filename": "hti_index-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1bfb01c4711fbbb773a7cc10bb06e3bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7374,
            "upload_time": "2023-04-21T06:32:13",
            "upload_time_iso_8601": "2023-04-21T06:32:13.170808Z",
            "url": "https://files.pythonhosted.org/packages/7c/0e/cba41e4ccde1c314e00c42c7da94d9794332c159d9f545414b4c6a1ce50c/hti_index-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6916537b7d5dec18c36cac8682eea8d834ccc72137fa6cc9ff51326d74dcf53",
                "md5": "6fffbec79b3dc6e6fae6e514c273fae5",
                "sha256": "9abf237915f0f108eaaa8aed5a801fcb6cc20ad43956d454327cabcde36c4d5c"
            },
            "downloads": -1,
            "filename": "hti_index-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "6fffbec79b3dc6e6fae6e514c273fae5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6863,
            "upload_time": "2023-04-21T06:32:17",
            "upload_time_iso_8601": "2023-04-21T06:32:17.793505Z",
            "url": "https://files.pythonhosted.org/packages/c6/91/6537b7d5dec18c36cac8682eea8d834ccc72137fa6cc9ff51326d74dcf53/hti_index-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-21 06:32:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "diomandeee",
    "github_project": "hti_index",
    "lcname": "hti-index"
}
        
Elapsed time: 0.14733s