-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from singnet/feature/issue-114-create-method-…
…to-create-indexes [#114] Add create_field_index() to RedisMongoDB adapter
- Loading branch information
Showing
7 changed files
with
246 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
[#112] Fix return of the functions get_matched_links(), get_incoming_links(), get_matched_type_template(), get_matched_type() from set to list | ||
[#112] Fix return of the functions get_matched_links(), get_incoming_links(), get_matched_type_template(), get_matched_type() from set to list | ||
[#114] Add create_field_index() to RedisMongoDB adapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Any, Tuple | ||
|
||
from hyperon_das_atomdb.utils.expression_hasher import ExpressionHasher | ||
|
||
|
||
class Index(ABC): | ||
@staticmethod | ||
def generate_index_id(field: str) -> str: | ||
"""Generates an index ID based on the field name. | ||
Args: | ||
field (str): The field name. | ||
Returns: | ||
str: The index ID. | ||
""" | ||
return f"index_{ExpressionHasher._compute_hash(field)}" | ||
|
||
@abstractmethod | ||
def create(self, field: str, **kwargs) -> Tuple[str, Any]: | ||
"""Creates an index on the given field. | ||
Args: | ||
field (str): The field to create the index on. | ||
Returns: | ||
Tuple[str, Any]: The index ID. | ||
""" | ||
... # pragma: no cover | ||
|
||
@abstractmethod | ||
def index_exists(self, index_id: str) -> bool: | ||
"""Checks if an index exists | ||
Args: | ||
index_id (str): The index ID. | ||
Returns: | ||
bool: True if the index exists, False otherwise. | ||
""" | ||
... # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters