Class DeletionChecker
Answers whether an entity ID has been deleted without any runtime network call. The dataset is
a set of packed binary files, one per entity type, plus a manifest describing the release. A
consumer selects which entity types to load with load(java.nio.file.Path, java.util.Set<java.lang.String>); unselected types are never opened
and incur no memory or startup cost.
The dataset is immutable for the lifetime of the instance — new deletions or a changed entity-type selection are picked up only by loading a new instance against an updated dataset. Lookups are exact: no false positives or negatives.
The mapped files are held for the life of the process; there is no close. Their pages
are off-heap, file-backed memory that counts toward process RSS and container memory limits,
not toward the Java heap.
Instances are thread-safe after load(java.nio.file.Path, java.util.Set<java.lang.String>) returns.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the loaded release'sdatasetVersion— the ISO-8601 timestamp identifying which generation run's deletion data this instance holds.<T> List<T> Returns the items whose extracted identifier is not recorded as deleted forentityType, in their original order.booleanReturns whetheridis recorded as deleted forentityType.static DeletionCheckerLoads the requested entity types from the dataset indatasetDirectory.loadedAt()Returns the instantload(java.nio.file.Path, java.util.Set<java.lang.String>)completed, i.e.
-
Method Details
-
load
public static DeletionChecker load(Path datasetDirectory, Set<String> entityTypes) throws IOException Loads the requested entity types from the dataset indatasetDirectory.Reads and verifies
manifest.json, confirms every requested entity type is listed in it, then for each requested type opens its packed file, checks its format version and header entity type, and verifies its checksum against the manifest. Any failure fails the load; partially loaded state is discarded. Entity types not requested are never opened.- Parameters:
datasetDirectory- the directory holdingmanifest.jsonand the packed filesentityTypes- the entity types to load- Returns:
- a checker over the loaded entity types
- Throws:
NullPointerException- ifdatasetDirectoryorentityTypesis nullIOException- if the manifest or a requested type's file cannot be readIllegalArgumentException- if a requested entity type is not listed in the manifestInvalidManifestException- if the manifest is malformed or fails its checksumUnsupportedManifestVersionException- if the manifest's schema version is not the one this build readsCorruptDatasetException- if a requested type's file is corrupt, its header entity type does not match the manifest, or its checksum does not match the manifestUnsupportedFormatVersionException- if a requested type's file has a binary format version this build does not read
-
isDeleted
Returns whetheridis recorded as deleted forentityType.The result is exact —
trueonly if this identifier is present in the loaded dataset for this entity type. Comparison is on the identifier's raw UTF-8 bytes; no hashing and no Unicode normalization is performed, so the caller must supply the identifier exactly as issued by the authoritative source.- Parameters:
entityType- the entity type to query; must have been requested when this instance was loadedid- the identifier to check- Returns:
trueif the identifier is deleted for this entity type,falseotherwise- Throws:
IllegalArgumentException- ifentityTypewas not requested when this instance was loaded, or ifidis null, empty, exceeds 64 bytes when UTF-8 encoded, or contains an unpaired surrogate
-
filter
Returns the items whose extracted identifier is not recorded as deleted forentityType, in their original order.Equivalent to calling
isDeleted(java.lang.String, java.lang.String)on each item's extracted identifier and keeping those that are not deleted, but resolvesentityTypeonce for the whole batch.- Type Parameters:
T- the item type- Parameters:
entityType- the entity type to query; must have been requested when this instance was loadeditems- the items to filteridExtractor- maps an item to the identifier to check- Returns:
- a new list containing only the items that are not deleted, in input order
- Throws:
NullPointerException- ifitemsoridExtractoris nullIllegalArgumentException- ifentityTypewas not requested when this instance was loaded, or if an extracted identifier is null, empty, exceeds 64 bytes when UTF-8 encoded, or contains an unpaired surrogate
-
datasetVersion
Returns the loaded release'sdatasetVersion— the ISO-8601 timestamp identifying which generation run's deletion data this instance holds.- Returns:
- the dataset version string
-
loadedAt
Returns the instantload(java.nio.file.Path, java.util.Set<java.lang.String>)completed, i.e. when this instance's dataset became active. Operators use it withdatasetVersion()to spot instances running a stale release.- Returns:
- the load-completion instant
-