Class PackedDeletionSet

java.lang.Object
com.marksayson.deletionchecker.format.PackedDeletionSet

public final class PackedDeletionSet extends Object
One entity type's packed file, memory-mapped and queried for exact membership.

open(java.nio.file.Path, java.lang.String) maps the file, checks the magic bytes and format version (v1 and v2 both read), verifies the whole-file CRC32C, confirms the header's entity type, and lifts the small prefix-index tables onto the heap (they are hot and reused by every query); the identifier offset table, identifier data, and Bloom filter stay in the mapping. The mapping is held for the life of this object — the dataset is immutable and there is no close.

contains(byte[]) reads the mapping by absolute index only and holds no mutable state, so an instance is safe for concurrent callers.

  • Method Details

    • open

      public static PackedDeletionSet open(Path path, String expectedEntityType) throws IOException
      Maps and validates the packed file at path.
      Parameters:
      path - the packed file
      expectedEntityType - the entity type the caller expects this file to hold (from the manifest)
      Returns:
      a queryable view of the file
      Throws:
      IOException - if the file cannot be opened or mapped
      CorruptDatasetException - if the file is truncated, its magic bytes are wrong, its checksum does not match, or its entity type is not expectedEntityType
      UnsupportedFormatVersionException - if the file's format version is one this build cannot read
    • contains

      public boolean contains(byte[] id)
      Returns whether id is recorded as deleted for this entity type.

      When the file has a Bloom filter (format v2), it is consulted first: a "definitely not present" is returned immediately without touching the prefix index or the offset table, which is the common negative-lookup case; a "maybe" falls through to the exact two-level search, so the result is always exact.

      Parameters:
      id - the identifier to check, UTF-8 encoded
      Returns:
      true if id is present, false otherwise
    • entityType

      public String entityType()
      Returns the entity type this file holds, as read from its header.
      Returns:
      the entity type
    • identifierCount

      public int identifierCount()
      Returns the number of identifiers in this file.
      Returns:
      the identifier count
    • checksum

      public long checksum()
      Returns this file's CRC32C, as read from its header and already verified against the file's actual bytes by open(java.nio.file.Path, java.lang.String), as an unsigned 32-bit value in the low bits of the result.
      Returns:
      the file checksum