Class TreeSession
- java.lang.Object
-
- org.apache.jackrabbit.oak.index.indexer.document.tree.store.TreeSession
-
public class TreeSession extends Object
A session that allows reading and writing keys and values in a tree store.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCACHE_SIZE_MBstatic StringLEAF_PREFIXstatic StringROOT_NAME
-
Constructor Summary
Constructors Constructor Description TreeSession()TreeSession(Store store)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckpoint()Make the current tree read-only and switch to a new root.Iterable<Map.Entry<String,String>>entrySet()voidflush()Flush all changes to storage.Stringget(String key)Get an entry.StringgetApproximateMedianKey(String low, String high, Random r)static StringgetFileNameRegex()longgetFileReadCount()Get the number of files read from the cache or storage.StringgetInfo()StringgetMaxKey()intgetMaxRoots()StringgetMinKey()intgetRootCount()Get the number of roots.voidinit()Initialize the storage, creating a new root if needed.Iterator<Map.Entry<String,String>>iterator()Get all entries.Iterator<Map.Entry<String,String>>iterator(String largerThan)Get all entries.Iterable<String>keys()Return all keys in sorted order.Iterable<String>keys(String largerThan)Return all keys in sorted order.voidmergeRoots(int max)Merge a number of roots.voidput(String key, String value)Put a value.voidrunGC()voidsetMaxRoots(int maxRoots)Set the maximum number of roots.
-
-
-
Field Detail
-
CACHE_SIZE_MB
public static final String CACHE_SIZE_MB
- See Also:
- Constant Field Values
-
ROOT_NAME
public static final String ROOT_NAME
- See Also:
- Constant Field Values
-
LEAF_PREFIX
public static final String LEAF_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TreeSession
public TreeSession()
-
TreeSession
public TreeSession(Store store)
-
-
Method Detail
-
getFileNameRegex
public static String getFileNameRegex()
-
setMaxRoots
public void setMaxRoots(int maxRoots)
Set the maximum number of roots.- Parameters:
maxRoots- the new value
-
getMaxRoots
public int getMaxRoots()
-
getFileReadCount
public long getFileReadCount()
Get the number of files read from the cache or storage.- Returns:
- the result
-
init
public void init()
Initialize the storage, creating a new root if needed.
-
get
public String get(String key)
Get an entry.- Parameters:
key- the key- Returns:
- the value, or null
-
put
public void put(String key, String value)
Put a value. To remove an entry, the value needs to be null.- Parameters:
key- the keyvalue- the value
-
mergeRoots
public void mergeRoots(int max)
Merge a number of roots. Merging will create a new root, which contains the data of the previous roots. If there are less roots, this method returns without merging.- Parameters:
max- the number of roots to merge (Integer.MAX_VALUE for all)
-
getRootCount
public int getRootCount()
Get the number of roots.- Returns:
- the number of roots
-
checkpoint
public void checkpoint()
Make the current tree read-only and switch to a new root. If there are already too many roots, then they will be merged. All changes are flushed to storage.
-
flush
public void flush()
Flush all changes to storage.
-
iterator
public Iterator<Map.Entry<String,String>> iterator()
Get all entries. Do not add or move entries while iterating.- Returns:
- the result
-
iterator
public Iterator<Map.Entry<String,String>> iterator(String largerThan)
Get all entries. Do not add or move entries while iterating.- Parameters:
largerThan- all returned keys are larger than this; null to start at the beginning- Returns:
- the result
-
keys
public Iterable<String> keys()
Return all keys in sorted order. Roots don't need to be merged.- Returns:
- all keys
-
keys
public Iterable<String> keys(String largerThan)
Return all keys in sorted order.- Parameters:
largerThan- all returned keys are larger than this; null to start at the beginning- Returns:
- the keys
-
runGC
public void runGC()
-
getInfo
public String getInfo()
-
getMinKey
public String getMinKey()
-
getMaxKey
public String getMaxKey()
-
-