in python/src/tablestore_for_agent_memory/util/tablestore_helper.py [0:0]
def row_to_session(row: Optional[tablestore.Row]) -> Optional[Session]:
if row is None:
return None
if len(row.primary_key) == 2:
user_id = row.primary_key[0][1]
session_id = row.primary_key[1][1]
update_time = None
else:
user_id = row.primary_key[0][1]
update_time = row.primary_key[1][1]
session_id = row.primary_key[2][1]
metadata = {}
for col in row.attribute_columns:
key = col[0]
val = col[1]
if key == "update_time":
update_time = val
continue
metadata[key] = val
return Session(
user_id=user_id,
session_id=session_id,
update_time=update_time,
metadata=metadata,
)