T - the type of values stored in this indexpublic class Wormhole<T>
extends java.lang.Object
This implementation supports fast lookups, inserts, deletes, and range scans. Keys are String only.
| Modifier and Type | Field and Description |
|---|---|
static char |
BITMAP_ID_OF_SMALLEST_TOKEN |
static java.lang.String |
SMALLEST_TOKEN |
| Constructor and Description |
|---|
Wormhole()
Creates a Wormhole with the default leaf node size.
|
Wormhole(int leafNodeSize)
Creates a Wormhole with the specified leaf node size.
|
Wormhole(int leafNodeSize,
boolean debugMode)
Creates a Wormhole with the specified leaf node size and optional debug mode.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete(java.lang.String key)
Deletes a key-value pair if present.
|
T |
get(java.lang.String key)
Retrieves the value associated with the specified key.
|
void |
put(java.lang.String key,
T value)
Inserts or updates a key-value pair.
|
void |
scan(java.lang.String startKey,
java.lang.String endKey,
boolean isEndKeyExclusive,
java.util.function.Function<KeyValue<T>,java.lang.Boolean> function)
Scans a range of keys and applies a function to each result.
|
java.util.List<KeyValue<T>> |
scanWithCount(java.lang.String startKey,
int count)
Scans the index starting from a key and collects up to
count pairs. |
void |
scanWithExclusiveEndKey(java.lang.String startKey,
java.lang.String endKey,
java.util.function.Function<KeyValue<T>,java.lang.Boolean> function)
Scans a range of keys where the end key is exclusive.
|
void |
scanWithInclusiveEndKey(java.lang.String startKey,
java.lang.String endKey,
java.util.function.Function<KeyValue<T>,java.lang.Boolean> function)
Scans a range of keys where the end key is inclusive.
|
java.lang.String |
toString() |
public static final java.lang.String SMALLEST_TOKEN
public static final char BITMAP_ID_OF_SMALLEST_TOKEN
public Wormhole()
public Wormhole(int leafNodeSize)
leafNodeSize - maximum number of entries in a leaf nodepublic Wormhole(int leafNodeSize,
boolean debugMode)
leafNodeSize - maximum number of entries in a leaf nodedebugMode - enables internal consistency checks if truepublic void put(java.lang.String key,
T value)
key - the key (must not be null)value - the value to associate with the keypublic boolean delete(java.lang.String key)
key - the key to removetrue if the key was removed, false otherwise@Nullable public T get(java.lang.String key)
key - the key to search fornull if not foundpublic java.util.List<KeyValue<T>> scanWithCount(java.lang.String startKey, int count)
count pairs.startKey - the starting key (inclusive)count - maximum number of results to returnpublic void scan(@Nullable
java.lang.String startKey,
@Nullable
java.lang.String endKey,
boolean isEndKeyExclusive,
java.util.function.Function<KeyValue<T>,java.lang.Boolean> function)
startKey - the start key (inclusive) or null for the first keyendKey - the end key (exclusive or inclusive based on isEndKeyExclusive)isEndKeyExclusive - whether endKey is exclusivefunction - a function applied to each key-value pair; return false to stop
scanningpublic void scanWithExclusiveEndKey(@Nullable
java.lang.String startKey,
@Nullable
java.lang.String endKey,
java.util.function.Function<KeyValue<T>,java.lang.Boolean> function)
startKey - the start key (inclusive) or null for the first keyendKey - the end key (exclusive)function - a function applied to each key-value pair; return false to stop
scanningpublic void scanWithInclusiveEndKey(@Nullable
java.lang.String startKey,
@Nullable
java.lang.String endKey,
java.util.function.Function<KeyValue<T>,java.lang.Boolean> function)
startKey - the start key (inclusive) or null for the first keyendKey - the end key (inclusive)function - a function applied to each key-value pair; return false to stop
scanningpublic java.lang.String toString()
toString in class java.lang.Object