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
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
ConstructorDescriptionIBSkipSpan
(BlockFile bf, BSkipList<K, V> bsl, int spanPage, Serializer<K> key, Serializer<V> val) -
Method Summary
Modifier and TypeMethodDescriptionfirstKey()
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 keyLinear search if in file, Binary search if in memoryLoad 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 memorynewInstance
(SkipList<K, V> sl) Load whole span from file, do the operation, flush out, then null out in-memory data again.Object[]
Load whole span from file, do the operation, flush out, then null out in-memory data again.(package private) void
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:
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
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
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.
-