ArcticDB icon indicating copy to clipboard operation
ArcticDB copied to clipboard

`lib_tool.read_to_keys` doesn't work for some `KeyType`s

Open IvoDD opened this issue 5 months ago • 0 comments

Describe the bug

lib_tool.read_to_keys crashes for KeyType.VERSION_REF

lib_tool.read_to_keys gives wrong index keys when reading KeyType.VERSION

There are maybe other problematic key types but we lack testing. We need to add thorough tests that verify we can hop around the version chain without issues over all key types.

Steps/Code to Reproduce

from arcticdb import Arctic
from arcticdb.toolbox.library_tool import KeyType
import pandas as pd

ac = Arctic("lmdb://data/arcticdb")
ac.delete_library("vel_test")
lib = ac.get_library("vel_test", create_if_missing=True)
lib_tool = lib._nvs.library_tool()
sym = "sym"

# Write a single version
df = pd.DataFrame({"data": [1]}, index=[pd.Timestamp("2024-09-09")])
lib.write(sym, df)

# Fails to read ref key
ref_key = lib_tool.find_keys_for_id(KeyType.VERSION_REF, sym)[0]
try:
    lib_tool.read_to_keys(ref_key)
except Exception as e:
    print(e) # This gives "std::bad_variant_access(std::get: wrong index for variant)"

# Reads wrong index keys from version key
ver_key = lib_tool.find_keys_for_id(KeyType.VERSION, sym)[0]
print(lib_tool.read_to_keys(ver_key)) # This gives "[i:sym:0:0xe79e1d6ff40aaa66@1726559612750387819[1725840000,1725840000000000001]]" which has an obviously wrong start_index

Expected Results

lib_tool.read_to_keys correctly read all key types which contain keys (VERSION_REF, VERSION, INDEX) lib_tool.read_to_dataframe works on all key types.

OS, Python Version and ArcticDB Version

Every version.

Backend storage used

No response

Additional Context

No response

IvoDD avatar Sep 17 '24 07:09 IvoDD