Class IdDokladuCacheImpl
java.lang.Object
cz.drg.pregrouper.process.fileRead.IdDokladuCacheImpl
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntries(IdDokladuOffset[] entries) Appends entries, which must arrive in ascending key order and must continue the order established by previous calls.static intcompare(long hi1, long lo1, long hi2, long lo2) static longencodeHalf(String s, int from) Encodes characters [from, from+10) into a long, treating positions past the end of the key as the reserved "absent" symbol 0.intfind(long kHi, long kLo) Exact lookup over the FILLED range only.voidforceSetMaximumCacheEntries(int maximumEntries) Sets the maximum number of entries that can be stored in the cache.static IdDokladuCacheImplvoidinit(long dataFileLength) booleanisSealed()static voidreset()Resets the cache to its initial state.voidseal()Freezes the cache and releases any unused tail.intsize()static inttoDigit(char c)
-
Field Details
-
LEN
public static final int LENMaximum key length. Keys may be anywhere from 0 to LEN characters.- See Also:
-
HALF
public static final int HALF- See Also:
-
RADIX
public static final int RADIX62 real symbols + 1 reserved value for "absent" (padding for short keys).- See Also:
-
-
Constructor Details
-
IdDokladuCacheImpl
public IdDokladuCacheImpl()
-
-
Method Details
-
getInstance
-
init
public void init(long dataFileLength) - Parameters:
dataFileLength- total byte length of the file being indexed; the last entry's group runs from its offset to here
-
forceSetMaximumCacheEntries
public void forceSetMaximumCacheEntries(int maximumEntries) Sets the maximum number of entries that can be stored in the cache. ONLY USED FOR TESTING.- Parameters:
maximumEntries-
-
reset
public static void reset()Resets the cache to its initial state. -
addEntries
Appends entries, which must arrive in ascending key order and must continue the order established by previous calls. Violations throw immediately rather than corrupting the binary search — this is the check that catches a data file sorted under a non-C locale or with a case-folding collator. It only fills up to the maximum available memory, any overflow will be stored on disk and used as a fallback search option. -
seal
public void seal()Freezes the cache and releases any unused tail. Must be called before get(). Trimming matters at scale: an index built with a generous capacity estimate would otherwise hold the slack forever. -
size
public int size() -
isSealed
public boolean isSealed() -
get
-
find
public int find(long kHi, long kLo) Exact lookup over the FILLED range only.- Returns:
- index of the key, or -(insertionPoint) - 1 if absent (same convention as Arrays.binarySearch)
-
encodeHalf
Encodes characters [from, from+10) into a long, treating positions past the end of the key as the reserved "absent" symbol 0. Always runs the full 10 iterations: that right-alignment is what makes numeric comparison agree with String.compareTo. -
toDigit
public static int toDigit(char c) - Returns:
- 1..62 for a real alphanumeric character (0 is reserved)
-
compare
public static int compare(long hi1, long lo1, long hi2, long lo2)
-