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
Modifier and Type Method Description KfirstKey()Does not call super, we always store first key herevoidflush()Flush to disk and null out in-memory keys and values, saving only the first keyVget(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 voidloadData()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) voidseekAndLoadData()Seek to the start of the span and load the data Package private so BSkipIterator can call itMethods inherited from class net.metanotion.io.block.index.BSkipSpan
init, killInstance, loadData, loadInit, lostEntries, toString
-
Constructor Details
-
IBSkipSpan
public IBSkipSpan(BlockFile bf, BSkipList<K,V> bsl, int spanPage, Serializer<K> key, Serializer<V> val) throws IOException- Throws:
IOException
-
-
Method Details
-
newInstance
- Overrides:
newInstancein 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
I2P - second half of load() Load the whole span's keys and values into memory- Overrides:
loadDatain classBSkipSpan<K extends Comparable<? super K>,V>- Throws:
IOException
-
seekAndLoadData
Seek to the start of the span and load the data Package private so BSkipIterator can call it- Throws:
IOException
-
firstKey
Does not call super, we always store first key here -
getSpan
Load whole span from file, do the operation, flush out, then null out in-memory data again. This is called only via SkipList.find() -
get
Linear search if in file, Binary search if in memory -
put
Load whole span from file, do the operation, flush out, then null out in-memory data again. -
remove
Load whole span from file, do the operation, flush out, then null out in-memory data again.
-