diff options
author | Alexander_Kabui | 2023-01-24 09:19:57 +0300 |
---|---|---|
committer | Alexander_Kabui | 2023-01-24 09:19:57 +0300 |
commit | 7012b68b1ee054004a6de8252e752f3d67612346 (patch) | |
tree | c166c208891702c7a1809d221ce2c88edd2221a2 /wqflask | |
parent | cf9871f97e065c210b72251458c9649c10a778ce (diff) | |
download | genenetwork2-7012b68b1ee054004a6de8252e752f3d67612346.tar.gz |
init read and write lmdb file
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/correlation/correlation_file_generator.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/wqflask/wqflask/correlation/correlation_file_generator.py b/wqflask/wqflask/correlation/correlation_file_generator.py index ccc06f3c..3b6a0984 100644 --- a/wqflask/wqflask/correlation/correlation_file_generator.py +++ b/wqflask/wqflask/correlation/correlation_file_generator.py @@ -146,9 +146,6 @@ def generate_csv_file(conn,db_name,txt_dir,file_name): raise e -def lmdb_file_generator(): - pass - def array_to_bytes(x:np.ndarray) -> bytes: @@ -162,4 +159,32 @@ def array_to_bytes(x:np.ndarray) -> bytes: def bytes_to_array(b: bytes) -> np.ndarray: np_bytes = BytesIO(b) - return np.load(np_bytes, allow_pickle=True)
\ No newline at end of file + return np.load(np_bytes, allow_pickle=True) + + +def lmdb_file_generator(file_name,data:np.ndarray): + + #create unique filename + + # pass + + +def create_dataset(file_name, db_name, dataset: np.ndarray): + + # map size int(ie12) + with lmdb.open(file_name, map_size=(dataset.nbytes*10)) as env: + with env.begin(write=True) as txn: + txn.put(db_name.encode(), array_to_bytes(dataset)) + + return (file_name, db_name) + + +def read_dataset(file_name, db_name): + with lmdb.open(file_name, readonly=True, create=False) as env: + with env.begin() as txn: + ndaray_bytes = txn.get(db_name.encode()) + # error handling + return bytes_to_array(ndaray_bytes) + + +#simple lmdb file
\ No newline at end of file |