Package net.metanotion.io.block.index
Class IBSkipSpan<K extends Comparable<? super K>,V>
- java.lang.Object
-
- net.metanotion.util.skiplist.SkipSpan<K,V>
-
- net.metanotion.io.block.index.BSkipSpan<K,V>
-
- net.metanotion.io.block.index.IBSkipSpan<K,V>
-
- All Implemented Interfaces:
Flushable
public class IBSkipSpan<K extends Comparable<? super K>,V> extends BSkipSpan<K,V>
I2P version of BSkipSpan BSkipSpan stores all keys and values in-memory, backed by the file. IBSkipSpan stores only the first key, and no values, in-memory. For a get(), here we do a linear search through the span in the file and load only the found value (super() does a binary search in-memory). For a put() or remove(), we load all keys and values for the span from the file, make the modification, flush() out the keys and values, and null out the keys and values in-memory. Recommended span size is 16.- Author:
- zzz
-
-
Field Summary
-
Fields inherited from class net.metanotion.io.block.index.BSkipSpan
bf, CONT_HEADER_LEN, HEADER_LEN, isKilled, keySer, MAGIC, nextPage, overflowPage, page, prevPage, spanSize, valSer
-
-
Constructor Summary
Constructors Constructor Description IBSkipSpan(BlockFile bf, BSkipList<K,V> bsl, int spanPage, Serializer<K> key, Serializer<V> val)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description K
firstKey()
Does not call super, we always store first key herevoid
flush()
Flush to disk and null out in-memory keys and values, saving only the first keyV
get(K key)
Linear search if in file, Binary search if in memorySkipSpan<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 memorySkipSpan<K,V>
newInstance(SkipList<K,V> sl)
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-
Methods inherited from class net.metanotion.io.block.index.BSkipSpan
init, killInstance, loadData, loadInit, lostEntries, toString
-
-
-
-
Constructor Detail
-
IBSkipSpan
public IBSkipSpan(BlockFile bf, BSkipList<K,V> bsl, int spanPage, Serializer<K> key, Serializer<V> val) throws IOException
- Throws:
IOException
-
-
Method Detail
-
newInstance
public SkipSpan<K,V> newInstance(SkipList<K,V> sl)
- Overrides:
newInstance
in classBSkipSpan<K extends Comparable<? super K>,V>
-
flush
public void flush()
Flush to disk and null out in-memory keys and values, saving only the first key
-
loadData
protected void loadData() throws IOException
I2P - second half of load() Load the whole span's keys and values into memory- Overrides:
loadData
in classBSkipSpan<K extends Comparable<? super K>,V>
- Throws:
IOException
-
seekAndLoadData
void seekAndLoadData() throws IOException
Seek to the start of the span and load the data Package private so BSkipIterator can call it- Throws:
IOException
-
firstKey
public K firstKey()
Does not call super, we always store first key here
-
getSpan
public 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. This is called only via SkipList.find()
-
put
public 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.
-
-