K - type of keys maintained by this skip spanV - type of values stored in this skip spanpublic class IBSkipSpan<K extends Comparable<? super K>,V> extends BSkipSpan<K,V>
Stores only first key in memory to reduce memory usage. Loads keys and values from disk on-demand during operations.
Comparison with BSkipSpan:
For get(): performs linear search through span in file and loads only found value (super() does binary search in-memory).
For put() or remove(): loads all keys and values for span from file, makes modification, flushes out keys and values, and nulls out keys and values in-memory.
Recommended span size is 16.
bf, CONT_HEADER_LEN, HEADER_LEN, isKilled, keySer, MAGIC, nextPage, overflowPage, page, prevPage, spanSize, valSer| Constructor and Description |
|---|
IBSkipSpan(BlockFile bf,
BSkipList<K,V> bsl,
int spanPage,
Serializer<K> key,
Serializer<V> val)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
K | firstKey()Does not call super, we always store first key here |
void | flush()Flush to disk and null out in-memory keys and values, saving only the first key |
V | get(K key)Linear search if in file, Binary search if in memory |
SkipSpan<K,V> | getSpan(K key,
int[] search)Load whole span from file, do the operation, flush out, then null out in-memory data again. |
protected void | loadData()I2P - second half of load()
Load the whole span's keys and values into memory |
SkipSpan<K,V> | newInstance(SkipList<K,V> sl)Create a new span instance for a page split. |
SkipSpan<K,V> | put(K key,
V val,
SkipList<K,V> sl)Load whole span from file, do the operation, flush out, then null out in-memory data again. |
Object[] | remove(K key,
SkipList<K,V> sl)Load whole span from file, do the operation, flush out, then null out in-memory data again. |
(package private) void | seekAndLoadData()Seek to the start of the span and load the data
Package private so BSkipIterator can call it |
init, killInstance, loadData, loadInit, lostEntries, toStringpublic IBSkipSpan(BlockFile bf, BSkipList<K,V> bsl, int spanPage, Serializer<K> key, Serializer<V> val) throws IOException
bf - the block filebsl - the B-skip listspanPage - page number of the spankey - key serializerval - value serializerIOException - on I/O errorpublic K firstKey()
public void flush()
public SkipSpan<K,V> getSpan(K key, int[] search)
protected void loadData()
throws IOExceptionloadData in class BSkipSpan<K extends Comparable<? super K>,V>IOException - if an I/O error occurspublic SkipSpan<K,V> newInstance(SkipList<K,V> sl)
newInstance in class BSkipSpan<K extends Comparable<? super K>,V>sl - the parent skip listpublic SkipSpan<K,V> put(K key, V val, SkipList<K,V> sl)
public Object[] remove(K key, SkipList<K,V> sl)
void seekAndLoadData()
throws IOExceptionIOException