1010import logging
1111import uuid
1212from datetime import datetime , timezone
13- from typing import TYPE_CHECKING
13+ from typing import TYPE_CHECKING , Any
1414
1515from orcapod .errors import SchemaVersionError
1616from orcapod .protocols .core_protocols import DataProtocol
1717from orcapod .protocols .database_protocols import ArrowDatabaseProtocol
1818from orcapod .system_constants import constants , RESULT_DB_SCHEMA_VERSION
19- from orcapod .types import ContentHash
2019from orcapod .utils .lazy_module import LazyModule
2120
2221if TYPE_CHECKING :
2928logger = logging .getLogger (__name__ )
3029
3130
32- def _hash_val_to_binary (val : "str | bytes | memoryview | None" ) -> "bytes | None" :
33- """Convert a ContentHash value to its prefixed binary digest.
34-
35- Tolerates both ``str`` (v0 format, passed through ``ContentHash.from_string``)
36- and ``bytes``/``memoryview`` (already binary v1 format, returned as-is).
37- Returns ``None`` for ``None`` inputs.
38- """
39- if val is None :
40- return None
41- if isinstance (val , (bytes , memoryview )):
42- return bytes (val )
43- return ContentHash .from_string (val ).to_prefixed_digest ()
44-
45-
4631# Process-level cache of v1 result DB paths that have already been checked for
4732# legacy v0 schema. Populated on first access; prevents repeated table_exists
4833# calls for the same path within a single process.
@@ -169,7 +154,7 @@ def _ensure_rdb_schema(self) -> None:
169154 def lookup (
170155 self ,
171156 input_data : DataProtocol ,
172- additional_constraints : dict [str , str ] | None = None ,
157+ additional_constraints : dict [str , Any ] | None = None ,
173158 ) -> DataProtocol | None :
174159 """Look up a cached output data for *input_data*.
175160
@@ -183,7 +168,9 @@ def lookup(
183168 input_data: The input data whose content hash is the
184169 primary lookup key.
185170 additional_constraints: Optional extra column-value pairs to
186- include in the lookup query.
171+ include in the lookup query. Values may be ``bytes`` (for
172+ binary hash columns) or other scalar types (e.g. ``str``
173+ for ``function_name``).
187174
188175 Returns:
189176 The cached output data with ``RESULT_COMPUTED_FLAG: False``
@@ -195,7 +182,7 @@ def lookup(
195182
196183 RECORD_ID_COL = "_record_id"
197184
198- constraints : dict [str , bytes ] = {
185+ constraints : dict [str , Any ] = {
199186 constants .INPUT_DATA_HASH_COL : input_data .content_hash ().to_prefixed_digest (),
200187 }
201188 if additional_constraints :
@@ -282,22 +269,6 @@ def store(
282269 )
283270 col_idx += 1
284271
285- # Convert ContentHash variation columns to large_binary (v1 schema).
286- # Tolerates both str (v0 format) and bytes/memoryview (already binary — pass through).
287- _HASH_VAR_COLS = {
288- f"{ constants .PF_VARIATION_PREFIX } function_signature_hash" ,
289- f"{ constants .PF_VARIATION_PREFIX } function_content_hash" ,
290- }
291- for col_name in _HASH_VAR_COLS :
292- if col_name in data_table .column_names :
293- col_idx = data_table .column_names .index (col_name )
294- raw_vals = data_table .column (col_name ).to_pylist ()
295- binary_vals = pa .array (
296- [_hash_val_to_binary (v ) for v in raw_vals ],
297- type = pa .large_binary (),
298- )
299- data_table = data_table .set_column (col_idx , col_name , binary_vals )
300-
301272 # Add input data hash as large_binary at position 0 (v1 schema).
302273 data_table = data_table .add_column (
303274 0 ,
0 commit comments