Class LmdbPageCardinalityEstimator
- All Implemented Interfaces:
Closeable, AutoCloseable
Callers supply the ID of the already-pinned LMDB read transaction. This class selects the newest valid meta page no
newer than that transaction, resolves the requested named database from that same snapshot, and shares decoded pages
only among estimates for that snapshot. When the transaction ID or native mapping changes, snapshot(long)
installs a fresh cache. This is the boundary that keeps low-level page reads consistent with the logical query view.
The production constructor receives the open LMDB environment so reads can be zero-copy views of LMDB's native map. The file-only constructor intentionally follows the same decoder through positional channel reads and exists for standalone callers and tests. Both paths must produce identical estimates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordReliability summary for one logical result, possibly combined across databases or physical layouts.static final recordEstimate and reliability evidence used byTripleStoreto decide whether another physical index is worth reading.static final recordPrecomputed description of how one logical statement-pattern shape maps to one physical LMDB index layout. -
Constructor Summary
ConstructorsConstructorDescriptionLmdbPageCardinalityEstimator(File dataMdbFile) File-channel fallback constructor, retained for compatibility and standalone tests.LmdbPageCardinalityEstimator(File dataMdbFile, long env) Native-map constructor used byTripleStore. -
Method Summary
Modifier and TypeMethodDescriptionstatic intbindingMask(long subject, long predicate, long object, long context) voidclose()combineDatabaseEstimates(LmdbPageCardinalityEstimator.Estimate first, LmdbPageCardinalityEstimator.Estimate second) Adds reliability evidence for disjoint explicit and inferred databases.combineIndexEstimates(LmdbPageCardinalityEstimator.CardinalityEstimate first, LmdbPageCardinalityEstimator.CardinalityEstimate second) Reconciles estimates of the same logical result obtained from different physical index layouts.voidconfigureIndexes(List<String> fieldSequences) Configures the immutable physical statement-index layouts used by this store.longestimateEntries(long txnId, String dbName, byte[] minKey, int minKeyLength, byte[] maxKey, int maxKeyLength, GroupMatcher matcher) longestimateEntries(long txnId, String dbName, byte[] minKey, int minKeyLength, byte[] maxKey, int maxKeyLength, GroupMatcher matcher, int residualFieldCount) estimateEntriesWithQuality(long txnId, String dbName, byte[] minKey, int minKeyLength, byte[] maxKey, int maxKeyLength, GroupMatcher matcher, int residualFieldCount) indexShape(int index, int bindingMask) intprimaryIndex(int bindingMask) intsecondaryIndex(int bindingMask) Returns-1when a separate physical layout would not add useful evidence.longtotalEntries(long txnId, String dbName)
-
Constructor Details
-
LmdbPageCardinalityEstimator
File-channel fallback constructor, retained for compatibility and standalone tests.- Throws:
IOException
-
LmdbPageCardinalityEstimator
Native-map constructor used byTripleStore. The environment handle lets page reads use LMDB's existing mapping without copying pages throughFileChannel.- Throws:
IOException
-
-
Method Details
-
configureIndexes
-
bindingMask
public static int bindingMask(long subject, long predicate, long object, long context) -
public int primaryIndex
(int bindingMask) -
secondaryIndex
public int secondaryIndex(int bindingMask) Returns-1when a separate physical layout would not add useful evidence. -
indexShape
-
combineDatabaseEstimates
public static LmdbPageCardinalityEstimator.CardinalityEstimate combineDatabaseEstimates(LmdbPageCardinalityEstimator.Estimate first, LmdbPageCardinalityEstimator.Estimate second) Adds reliability evidence for disjoint explicit and inferred databases. -
combineIndexEstimates
public static LmdbPageCardinalityEstimator.CardinalityEstimate combineIndexEstimates(LmdbPageCardinalityEstimator.CardinalityEstimate first, LmdbPageCardinalityEstimator.CardinalityEstimate second) Reconciles estimates of the same logical result obtained from different physical index layouts. -
estimateEntries
public long estimateEntries(long txnId, String dbName, byte[] minKey, int minKeyLength, byte[] maxKey, int maxKeyLength, GroupMatcher matcher) throws IOException - Throws:
IOException
-
estimateEntries
public long estimateEntries(long txnId, String dbName, byte[] minKey, int minKeyLength, byte[] maxKey, int maxKeyLength, GroupMatcher matcher, int residualFieldCount) throws IOException - Throws:
IOException
-
estimateEntriesWithQuality
public LmdbPageCardinalityEstimator.Estimate estimateEntriesWithQuality(long txnId, String dbName, byte[] minKey, int minKeyLength, byte[] maxKey, int maxKeyLength, GroupMatcher matcher, int residualFieldCount) throws IOException - Throws:
IOException
-
totalEntries
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-