Class PackedFileWriter
java.lang.Object
com.marksayson.deletionchecker.format.PackedFileWriter
Serializes one entity type's identifiers into a packed binary file (format v2): header, prefix
index, Bloom filter, identifier offset table, identifier data, with the file's CRC32C patched into
the header.
Build-time only — never invoked on the lookup path. Callers pass identifiers already sorted by
unsigned bytes and deduplicated; write(java.lang.String, java.util.List<byte[]>) verifies both and rejects violations rather than
producing a file that would fail mysteriously at query time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault Bloom-filter false-positive rate — seewrite(String, List, int, double). -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Serializes a packed file usingPrefixIndex.DEFAULT_BUCKET_SIZEandDEFAULT_BLOOM_FPR.static byte[]Serializes a packed file withDEFAULT_BLOOM_FPR.static byte[]Serializes a packed file.
-
Field Details
-
DEFAULT_BLOOM_FPR
public static final double DEFAULT_BLOOM_FPRDefault Bloom-filter false-positive rate — seewrite(String, List, int, double).- See Also:
-
-
Method Details
-
write
Serializes a packed file usingPrefixIndex.DEFAULT_BUCKET_SIZEandDEFAULT_BLOOM_FPR.- Parameters:
entityType- the entity type this file holds; ASCII, 1 to 64 bytessortedIdentifiers- the identifiers, already sorted by unsigned bytes and deduplicated- Returns:
- the complete file bytes
-
write
Serializes a packed file withDEFAULT_BLOOM_FPR.- Parameters:
entityType- the entity type this file holds; ASCII, 1 to 64 bytessortedIdentifiers- the identifiers, already sorted by unsigned bytes and deduplicatedbucketSize- the prefix index bucket target sizeK; must be at least 1- Returns:
- the complete file bytes
-
write
public static byte[] write(String entityType, List<byte[]> sortedIdentifiers, int bucketSize, double bloomFpr) Serializes a packed file.- Parameters:
entityType- the entity type this file holds; ASCII, 1 to 64 bytessortedIdentifiers- the identifiers, already sorted by unsigned bytes and deduplicatedbucketSize- the prefix index bucket target sizeK; must be at least 1bloomFpr- the Bloom filter's target false-positive rate;>= 1disables the filter, otherwise must be positive- Returns:
- the complete file bytes, with the CRC32C written into the header
- Throws:
IllegalArgumentException- ifsortedIdentifiersis not strictly ascending by unsigned bytes, ifentityTypeis not 1 to 64 ASCII bytes, ifbucketSizeis less than 1, or ifbloomFpris not positive
-