mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 12:28:07 +00:00
ifcparse: fixed-width hex ids in RocksDB keys, batched instance erasure
Review: recalculate_id_counter() scanned every i|<id>|_ record because ids were written as decimal text, which doesn't sort numerically. Make every numeric key segment fixed-width 16-digit lowercase hex, produced and parsed by key_to_string()/key_from_string() in rocksdb_map_adapter.h, with named builders (rocksdb_key::attribute, header_attribute, type_record, inverse, inverse_prefix, type_list, upper_bound) that the storage, entity_instance_data.cpp, read_schema() and the serializer use instead of assembling "i|" + std::to_string(id) + ... by hand. Keys now sort by id, an instance's records are contiguous in id order, and the largest id is the last key under i|, which recalculate_id_counter() seeks to. The two dormant to_string_fixed_width() helpers are gone. This changes the on-disk layout; databases converted before this commit have to be re-converted. Also review: instance_cache_ eviction went through an on-erase hook on set_to_map_transformer, a std::function call under a mutex per deleted instance. Drop the hook; file::remove_entity() and unbatch() call file::erase_instances_(ids), which on RocksDB is rocks_db_file_storage::erase_instances(): one WriteBatch of DeleteRanges and one lock for the whole batch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HNrXDmR88wKPCYwGE21SyH
This commit is contained in:
@@ -682,6 +682,10 @@ namespace ifcopenshell {
|
||||
// id counter is recalculated on the first create().
|
||||
bool id_counter_recalculated_ = false;
|
||||
|
||||
// Deletes every key of the given instances and drops their cached
|
||||
// handles, in one write and under one lock.
|
||||
void erase_instances(const std::vector<uint32_t>& ids);
|
||||
|
||||
// @todo all these size_ts should probably be uint32_t for consistency with in-mem storage
|
||||
|
||||
// lookup id->identity
|
||||
|
||||
Reference in New Issue
Block a user