Skip to content

Commit 193e49f

Browse files
author
Danil Tolmachev
committed
renaming
1 parent b1a2e8e commit 193e49f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

dictdatabase/io_unsafe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def partial_read_only(db_name: str, key: str) -> dict | None:
8888

8989
# Not found in index file, search for key in the entire file
9090
all_file_bytes = io_bytes.read(db_name)
91-
start, end, found = searching.search_value_by_key(all_file_bytes, key)
91+
start, end, found = searching.search_value_position_in_db(all_file_bytes, key)
9292
if not found:
9393
return None
9494
value_bytes = all_file_bytes[start:end]
@@ -185,7 +185,7 @@ def get_partial_file_handle(db_name: str, key: str) -> PartialFileHandle:
185185
return partial_handle
186186

187187
# Not found in index file, search for key in the entire file
188-
key_start, key_end, found = searching.search_key(all_file_bytes, key)
188+
key_start, key_end, found = searching.search_key_position_in_db(all_file_bytes, key)
189189

190190
if not found:
191191
raise KeyError(f"Key \"{key}\" not found in db \"{db_name}\"")

dictdatabase/searching.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dictdatabase import utils
77

88

9-
def find_start_end_in_bytes(file: bytes, key: str) -> Tuple[int, int, bool]:
9+
def find_key_position_in_bytes(file: bytes, key: str) -> Tuple[int, int, bool]:
1010
"""
1111
It finds the start and end indices of the value of a key in a JSON file
1212
@@ -25,7 +25,7 @@ def find_start_end_in_bytes(file: bytes, key: str) -> Tuple[int, int, bool]:
2525
return start, end, True
2626

2727

28-
def search_key(file: bytes, key: str, glom_searching=True) -> Tuple[int, int, bool]:
28+
def search_key_position_in_db(file: bytes, key: str, glom_searching=True) -> Tuple[int, int, bool]:
2929
original_value_start = 0
3030
original_value_end = len(file)
3131
original_key_start = 0
@@ -36,14 +36,14 @@ def search_key(file: bytes, key: str, glom_searching=True) -> Tuple[int, int, bo
3636
return -1, -1, False
3737
original_key_end = original_value_start + key_end
3838
original_key_start = original_value_start + key_start
39-
value_start, value_end, found = find_start_end_in_bytes(file, k)
39+
value_start, value_end, found = find_key_position_in_bytes(file, k)
4040
original_value_end = original_value_start + original_value_end
4141
original_value_start += value_start
4242
file = file[original_value_start:original_value_end]
4343
return original_key_start, original_key_end, True
4444

4545

46-
def search_value_by_key(
46+
def search_value_position_in_db(
4747
all_file_bytes: bytes, key: str, glom_searching=True
4848
) -> Tuple[int, int, bool]:
4949
"""
@@ -61,7 +61,7 @@ def search_value_by_key(
6161
original_start = 0
6262
original_end = len(all_file_bytes)
6363
for k in key.split(".") if glom_searching else [key]:
64-
start, end, found = find_start_end_in_bytes(
64+
start, end, found = find_key_position_in_bytes(
6565
all_file_bytes[original_start:original_end], k
6666
)
6767
if not found:

0 commit comments

Comments
 (0)