[CardDB] Stream card properties from blobs (#7608)

* [CardDB] Stream card properties from blobs

Parsed and cached cards used to keep a materialized QHash<QString,
QString> for their properties: LazyPropertiesHash only deferred building
that hash until the first query, and the cache writer re-serialized it on
save.

- LazyPropertiesHash answers value(), contains(), size(), isEmpty() and
  keys() straight out of the serialized blob, so a property query no
  longer builds a hash.
- serialize() is public, and the cache writer passes the stored blob
  through instead of serializing a hash it just rebuilt.
- CardInfo and PrintingInfo expose getPropertiesBlob() and
  getPropertyCount(); PrintingInfo::operator== compares key by key
  without materializing either side.
- The XML parsers build cards via newInstanceFromPropertiesBlob(), which
  derives the simple name and the alternate names that the parser used
  to keep next to the hash.

The reload cycle fix stays out of this change; it depends on changing
the CardInfo self pointer and is reviewed separately.

* [CardDB] Address review comments on streaming properties

* [CardDB] Address final review nits on property streaming

Move BlobReader and the blob accessors into LazyPropertiesHash as private
members so the parsing helper is declared with the class instead of hiding
in the translation unit.

Add LazyPropertiesHash::serializedFrom() and use it where a PrintingInfo is
built from a fresh property hash, replacing the nested
LazyPropertiesHash(LazyPropertiesHash::serialize(props)) construction.

The pre-materialized QHash constructor stays: CardInfo's non-blob factory
still uses it for the oracle import path, and the tests cover it directly.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-10-24 00:17:31 +02:00 • committed by GitHub
parent c25a2c5c3b
commit ad4320cd7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 475 additions and 59 deletions

View file

@ -67,10 +67,16 @@ CardInfo::CardInfo(const QString &_name,
reverseRelatedCards(_reverseRelatedCards), setsToPrintings(std::move(_sets)), uiAttributes(_uiAttributes),
altNames(std::move(_altNames))
{
// propertiesBlob is materialized lazily on first query; simpleName and
// altNames are supplied by the caller (binary cache). Only the set-name
// display list still depends on the current enabled-set state.
// propertiesBlob is materialized lazily on first query. The binary cache supplies simpleName
// and altNames to skip the Unicode normalization and the printing scan; the XML parsers leave
// them empty and get the same derived state the property-hash constructor computes.
if (simpleName.isEmpty()) {
simpleName = simplifyName(name);
}
refreshCachedSetNames();
if (altNames.isEmpty()) {
refreshCachedAltNames();
}
}
CardInfoPtr CardInfo::newInstance(const QString &_name)