Class AiResultCache
Cache entries are keyed by content_hash — the per-class SHA-256 fingerprint
produced by the -content-hash flag. A cache hit means the class source is identical
to the previous run; the stored AI classification is reused without an API call.
When the source CSV was produced without -content-hash, the content_hash
column is absent and no entries are loaded. All lookups return empty and the AI is called
normally for every class.
Instances are obtained via load(Path) or the no-op empty() singleton.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic AiResultCacheempty()Returns an empty cache that always produces misses.inthits()Returns the number of successful cache lookups so far.booleanisActive()Returnstruewhen this cache contains at least one entry.static AiResultCacheLoads a cache from a MethodAtlas CSV output file.Optional<org.egothor.methodatlas.ai.AiClassSuggestion> Returns the cached classification for the class with the given content hash, or empty when the hash is absent from the cache.intmisses()Returns the number of unsuccessful cache lookups so far.
-
Method Details
-
empty
Returns an empty cache that always produces misses. -
load
Loads a cache from a MethodAtlas CSV output file.Only rows with a non-empty
content_hashvalue and a non-nullai_security_relevantcolumn (AI was enabled for that scan) are included. Rows missing either field are silently skipped.- Parameters:
csvPath- path to a MethodAtlas CSV produced with-content-hash -ai- Returns:
- loaded cache; never
null - Throws:
IOException- if the file cannot be read
-
lookup
Returns the cached classification for the class with the given content hash, or empty when the hash is absent from the cache.- Parameters:
contentHash- SHA-256 fingerprint of the class source, ornull- Returns:
- cached suggestion, or empty on a miss or null hash
-
isActive
public boolean isActive()Returnstruewhen this cache contains at least one entry.When
false, content hashes do not need to be computed for lookups because all results would be misses regardless. -
hits
public int hits()Returns the number of successful cache lookups so far. -
misses
public int misses()Returns the number of unsuccessful cache lookups so far.
-