Skip to content
This repository was archived by the owner on Aug 25, 2022. It is now read-only.
Open
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
15 changes: 7 additions & 8 deletions skydb/skydb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import asyncio


def _equal(condition: dict, key: str, value: str, column_split: list = None) -> bool:
def _equal(condition: dict, key: str, value: str, *args, **kwargs) -> bool:
return condition[key] == value


Expand Down Expand Up @@ -85,7 +85,7 @@ def check_table(table_name: str, seed: str):
try:
index, revision = registry.get_entry(f"INDEX:{table_name}", timeout=5)
return int(index), revision
except Timeout as T:
except Timeout:
return None

def calibrate_index(self):
Expand All @@ -105,7 +105,7 @@ def get_index(self) -> int:
try:
index, revision = self.registry.get_entry(f"INDEX:{self.table_name}", timeout=5)
return int(index), revision
except Timeout as T:
except Timeout:
self.logger.debug("Initializing the index...")
self.registry.set_entry(data_key=f"INDEX:{self.table_name}", data=f"{0}", revision=1)
return (0, 1)
Expand Down Expand Up @@ -192,7 +192,6 @@ def add_rows(self, rows:list) -> list:
raise ValueError(f"Column {k} is empty")

tasks = []
row_indices = []
idx = self.index
for row in rows:
for c in row:
Expand Down Expand Up @@ -238,7 +237,7 @@ def update_row(self, row_index: int, data: dict):
self.logger.debug("Updating row at index: " + str(row_index))
self.logger.debug(data)
for k in data.keys():
old_data, revision = self.registry.get_entry(
_, revision = self.registry.get_entry(
data_key=f"{self.table_name}:{k}:{row_index}",
)
self.registry.set_entry(
Expand All @@ -260,7 +259,7 @@ def deprecated_fetch_row(self, row_index: int) -> dict:
self.logger.debug("Fetching row at index: " + str(row_index))
row = {}
for c in self.columns:
data, revision = self.registry.get_entry(data_key=f"{self.table_name}:{c}:{row_index}")
data, _ = self.registry.get_entry(data_key=f"{self.table_name}:{c}:{row_index}")
row[c] = data
return row

Expand Down Expand Up @@ -333,7 +332,7 @@ async def _fetch(self, condition: dict, n_rows: int, work_index: int, condition_
resp_data = await self.registry.aio_get_entry(
data_key=f"{self.table_name}:{k}:{work_index}"
)
data, revision = resp_data[f"{self.table_name}:{k}:{work_index}"]
data, _ = resp_data[f"{self.table_name}:{k}:{work_index}"]
if condition_func(condition, k, data,
self.column_split): # The value at the column matches the condition
keys_satisfy = True
Expand Down Expand Up @@ -563,7 +562,7 @@ async def aio_set_entry(self, data_key: str, data: str, revision: int):
""")


async def aio_get_entry(self, data_key: str, timeout: int = 30,) -> str:
async def aio_get_entry(self, data_key: str, *args, **kwargs) -> str:
"""
- Used aio requests to get data from skydb
"""
Expand Down