clash_data_serializer#
This module provides the abstract base class for clash data serialization.
Classes#
AbstractClashDataSerializer#
- class omni.physxclashdetectioncore.clash_data_serializer.AbstractClashDataSerializer#
A base class for serializing and managing clash data.
This abstract class defines the necessary methods for handling clash data serialization, including opening and closing files, managing data compatibility, and performing CRUD operations on clash data and related information. Implementations of this class should provide concrete definitions for the abstract methods.
Methods:
- __init__()#
Initializes the AbstractClashDataSerializer class.
- abstract open(file_path_name: str) None#
Creates a file or opens an existing.
- Parameters:
file_path_name (str) – Path of the file to open.
- abstract get_file_path() str#
Returns the serializer file path.
- Returns:
The file path of the serializer.
- Return type:
str
- abstract get_file_size() int#
Returns the serializer file size in bytes.
- Returns:
The file size in bytes.
- Return type:
int
- abstract data_structures_compatible() bool#
Returns True if the serializer has no compatibility issues (data structures, tables).
- Returns:
True if compatible, False otherwise.
- Return type:
bool
- abstract data_structures_migration_to_latest_version_possible() bool#
Returns True if the serializer can migrate data structures to the latest version.
- Returns:
True if migration to the latest version is possible.
- Return type:
bool
- abstract deferred_file_creation_until_first_write_op() bool#
Returns True if the serializer will postpone file creation until first write op is requested.
- Returns:
True if deferred creation is enabled, False otherwise.
- Return type:
bool
- abstract set_deferred_file_creation_until_first_write_op(value: bool)#
Sets if the serializer must postpone file creation until first write op is requested.
- Parameters:
value (bool) – Whether to defer file creation.
- set_on_modified_fnc(on_modified_fnc: Callable[[str], None] | None)#
Sets on_modified_fnc.
- Parameters:
on_modified_fnc (Optional[Callable[[str], None]]) – The function to call when modified.
- abstract is_open() bool#
Returns if the serializer is ready.
- Returns:
True if open, False otherwise.
- Return type:
bool
- abstract save() bool#
Saves data to the target file.
- Returns:
True if save was successful, False otherwise.
- Return type:
bool
- abstract close() None#
Closes the opened file.
- abstract commit() None#
Writes any unwritten data to the file. Committing bigger batches is advised.
- abstract migrate_data_structures_to_latest_version(file_path_name: str) bool#
Migrates data structures to the latest versions.
- Parameters:
file_path_name (str) – Path to the clash data.
- Returns:
True if migration was successful, False otherwise.
- Return type:
bool
- abstract insert_overlap(
- clash_info: ClashInfo,
- insert_also_frame_info: bool,
- update_identifier: bool,
- commit: bool,
Inserts clash data. If already present, insertion is skipped.
- Parameters:
clash_info (ClashInfo) – Clash information to insert.
insert_also_frame_info (bool) – Whether to insert frame info.
update_identifier (bool) – Whether to update the identifier.
commit (bool) – Whether to commit the operation.
- Returns:
ID of the new record.
- Return type:
int
- abstract update_overlap(
- clash_info: ClashInfo,
- update_also_frame_info: bool,
- commit: bool,
Updates clash data if present in the DB.
- Parameters:
clash_info (ClashInfo) – Clash information to update.
update_also_frame_info (bool) – Whether to update frame info.
commit (bool) – Whether to commit the operation.
- Returns:
Number of affected records.
- Return type:
int
- abstract find_all_overlaps_by_query_id(
- clash_query_id: int,
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
- num_overlaps_to_load: int = -1,
- first_overlap_offset: int = 0,
Finds all overlaps associated with a specific query ID.
- Parameters:
clash_query_id (int) – The ID of the query to search for overlaps.
fetch_also_frame_info (bool) – If True, fetches frame information associated with each ClashInfo object.
num_frames_to_load (int) – The maximum number of frames to load. Defaults to -1 (all frames).
first_frame_offset (int) – The offset for the first frame to load. Defaults to 0.
num_overlaps_to_load (int) – The maximum number of overlaps to load. Defaults to -1 (all overlaps).
first_overlap_offset (int) – The offset for the first overlap to load. Defaults to 0.
- Returns:
A dictionary where keys are overlap IDs and values are ClashInfo objects.
- Return type:
Dict[str, ClashInfo]
- abstract get_overlaps_count_by_query_id(clash_query_id: int) int#
Gets the total number of overlaps for a specific query ID.
- Parameters:
clash_query_id (int) – The ID of the query to count overlaps for.
- Returns:
The total number of overlaps for the query. Returns 0 if no results found.
- Return type:
int
- abstract get_overlaps_count_by_query_id_grouped_by_state(
- clash_query_id: int,
Gets the total number of overlaps for a specific query ID grouped by state.
- Parameters:
clash_query_id (int) – The ID of the query to count overlaps for.
- Returns:
A dictionary where keys are ClashState values and values are counts.
- Return type:
Dict[ClashState, int]
- abstract find_all_overlaps_by_overlap_id(
- overlap_id: Sequence[int],
- fetch_also_frame_info: bool,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Finds all overlaps by their overlap IDs.
- Parameters:
overlap_id (Sequence[int]) – A sequence of overlap IDs to search for.
fetch_also_frame_info (bool) – If True, fetches frame information.
num_frames_to_load (int) – The maximum number of frames to load. Defaults to -1 (all frames).
first_frame_offset (int) – The offset for the first frame to load. Defaults to 0.
- Returns:
A dictionary where keys are overlap IDs and values are ClashInfo objects.
- Return type:
Dict[str, ClashInfo]
- abstract remove_all_overlaps_by_query_id(
- clash_query_id: int,
- commit: bool,
Deletes specified clash data related to query_id. If not present, nothing happens.
- Parameters:
clash_query_id (int) – The query ID to remove.
commit (bool) – Whether to commit the operation.
- Returns:
Number of deleted rows.
- Return type:
int
- abstract remove_overlap_by_id(overlap_id: int, commit: bool) int#
Deletes specified clash data. If not present, nothing happens.
- Parameters:
overlap_id (int) – The overlap ID to remove.
commit (bool) – Whether to commit the operation.
- Returns:
Number of deleted rows.
- Return type:
int
- abstract fetch_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- num_frames_to_load: int = -1,
- first_frame_offset: int = 0,
Fetches frame information associated with a specific clash.
- Parameters:
clash_info_id (int) – The ID of the clash for which frame information is to be fetched.
num_frames_to_load (int) – The maximum number of frames to load. Defaults to -1 (all frames).
first_frame_offset (int) – The offset for the first frame to load. Defaults to 0.
- Returns:
A list of ClashFrameInfo objects.
- Return type:
Sequence[ClashFrameInfo]
- abstract get_clash_frame_info_count_by_clash_info_id(clash_info_id: int) int#
Gets the total number of frame info records for a specific clash info ID.
- Parameters:
clash_info_id (int) – The ID of the clash info to count frame info records for.
- Returns:
The total number of frame info records. Returns 0 if no results found.
- Return type:
int
- abstract insert_clash_frame_info_from_clash_info(
- clash_info: ClashInfo,
- commit: bool,
Inserts clash_frame_info from ClashInfo.
- Parameters:
clash_info (ClashInfo) – The ClashInfo object to extract frame info from.
commit (bool) – Whether to commit the change.
- Returns:
Number of affected records.
- Return type:
int
- abstract insert_clash_frame_info(
- clash_frame_info: ClashFrameInfo,
- clash_info_id: int,
- commit: bool,
Inserts clash_frame_info.
- Parameters:
clash_frame_info (ClashFrameInfo) – The ClashFrameInfo object to insert.
clash_info_id (int) – The ID of the associated ClashInfo.
commit (bool) – Whether to commit the change.
- Returns:
ID of the new record.
- Return type:
int
- abstract remove_clash_frame_info_by_clash_info_id(
- clash_info_id: int,
- commit: bool,
Deletes specified clash_frame_info data.
- Parameters:
clash_info_id (int) – The ID of the associated ClashInfo.
commit (bool) – Whether to commit the change.
- Returns:
Number of deleted rows.
- Return type:
int
- abstract fetch_all_queries() Dict[int, ClashQuery]#
Returns all clash queries.
- Returns:
Dictionary of all clash queries. Key is query identifier, value is ClashQuery object.
- Return type:
Dict[int, ClashQuery]
- abstract insert_query(
- clash_query: ClashQuery,
- update_identifier: bool,
- commit: bool,
Inserts clash query.
- Parameters:
clash_query (ClashQuery) – The ClashQuery object to insert.
update_identifier (bool) – Whether to update the identifier.
commit (bool) – Whether to commit the change.
- Returns:
ID of the new record.
- Return type:
int
- abstract find_query(clash_query_id: int) ClashQuery | None#
Returns specified clash query.
- Parameters:
clash_query_id (int) – The ID of the ClashQuery to find.
- Returns:
The found ClashQuery or None.
- Return type:
Optional[ClashQuery]
- abstract update_query(clash_query: ClashQuery, commit: bool) int#
Updates clash query if present in the DB.
- Parameters:
clash_query (ClashQuery) – The ClashQuery object to update.
commit (bool) – Whether to commit the change.
- Returns:
Number of affected records.
- Return type:
int
- abstract remove_query_by_id(query_id: int, commit: bool) int#
Deletes specified clash data.
- Parameters:
query_id (int) – The ID of the query to remove.
commit (bool) – Whether to commit the change.
- Returns:
Number of deleted rows.
- Return type:
int
Properties:
- on_modified_fnc: Callable[[str], None] | None#
Gets the on_modified function callback.