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) |
| 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 instance of this span type.
|
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
IOExceptionpublic K firstKey()
public void flush()
public SkipSpan<K,V> getSpan(K key, int[] search)
protected void loadData()
throws IOException
loadData in class BSkipSpan<K extends Comparable<? super K>,V>IOException - if an I/O error occurspublic SkipSpan<K,V> newInstance(SkipList<K,V> sl)
BSkipSpannewInstance in class BSkipSpan<K extends Comparable<? super K>,V>sl - the SkipList to create the span forpublic SkipSpan<K,V> put(K key, V val, SkipList<K,V> sl)
public Object[] remove(K key, SkipList<K,V> sl)
remove in class SkipSpan<K extends Comparable<? super K>,V>key - the key to removesl - the SkipListvoid seekAndLoadData()
throws IOException
IOException