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 String
CACHE_SIZE_MB
static String
LEAF_PREFIX
static String
ROOT_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 void
checkpoint()
Make the current tree read-only and switch to a new root.Iterable<Map.Entry<String,String>>
entrySet()
void
flush()
Flush all changes to storage.String
get(String key)
Get an entry.String
getApproximateMedianKey(String low, String high, Random r)
static String
getFileNameRegex()
long
getFileReadCount()
Get the number of files read from the cache or storage.String
getInfo()
String
getMaxKey()
int
getMaxRoots()
String
getMinKey()
int
getRootCount()
Get the number of roots.void
init()
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.void
mergeRoots(int max)
Merge a number of roots.void
put(String key, String value)
Put a value.void
runGC()
void
setMaxRoots(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()
-
-