Package net.metanotion.io.block.index
Class BSkipSpan<K extends Comparable<? super K>,V>
- java.lang.Object
-
- net.metanotion.util.skiplist.SkipSpan<K,V>
-
- net.metanotion.io.block.index.BSkipSpan<K,V>
-
- All Implemented Interfaces:
Flushable
- Direct Known Subclasses:
IBSkipSpan
public class BSkipSpan<K extends Comparable<? super K>,V> extends SkipSpan<K,V>
On-disk format:First Page: Magic number (int) overflow page (unsigned int) previous page (unsigned int) next page (unsigned int) max keys (unsigned short) number of keys (unsigned short) for each key: key length (unsigned short) value length (unsigned short) key data value data Overflow pages: Magic number (int) next overflow page (unsigned int)
-
-
Field Summary
Fields Modifier and Type Field Description protected BlockFilebfstatic intCONT_HEADER_LENprotected static intHEADER_LENprotected booleanisKilledprotected Serializer<K>keySerprotected static intMAGICprotected intnextPageprotected intoverflowPageprotected intpageprotected intprevPageprotected intspanSizeprotected Serializer<V>valSer
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()static voidinit(BlockFile bf, int page, int spanSize)voidkillInstance()protected voidloadData()I2P - second half of load() Load the whole span's keys and values into memoryprotected voidloadData(boolean flushOnError)I2P - second half of load() Load the whole span's keys and values into memoryprotected static <X extends Comparable<? super X>,Y>
voidloadInit(BSkipSpan<X,Y> bss, BlockFile bf, BSkipList<X,Y> bsl, int spanPage, Serializer<X> key, Serializer<Y> val)I2P - first half of load() Only read the span headersprotected voidlostEntries(int firstBadEntry, int lastGoodPage)Attempt to recover from corrupt data in this span.SkipSpan<K,V>newInstance(SkipList<K,V> sl)StringtoString()
-
-
-
Field Detail
-
MAGIC
protected static final int MAGIC
- See Also:
- Constant Field Values
-
HEADER_LEN
protected static final int HEADER_LEN
- See Also:
- Constant Field Values
-
CONT_HEADER_LEN
public static final int CONT_HEADER_LEN
- See Also:
- Constant Field Values
-
bf
protected final BlockFile bf
-
page
protected int page
-
overflowPage
protected int overflowPage
-
prevPage
protected int prevPage
-
nextPage
protected int nextPage
-
keySer
protected Serializer<K extends Comparable<? super K>> keySer
-
valSer
protected Serializer<V> valSer
-
spanSize
protected int spanSize
-
isKilled
protected boolean isKilled
-
-
Constructor Detail
-
BSkipSpan
public BSkipSpan(BlockFile bf, BSkipList<K,V> bsl, int spanPage, Serializer<K> key, Serializer<V> val) throws IOException
- Throws:
IOException
-
-
Method Detail
-
init
public static void init(BlockFile bf, int page, int spanSize) throws IOException
- Throws:
IOException
-
newInstance
public SkipSpan<K,V> newInstance(SkipList<K,V> sl)
- Overrides:
newInstancein classSkipSpan<K extends Comparable<? super K>,V>
-
killInstance
public void killInstance()
- Overrides:
killInstancein classSkipSpan<K extends Comparable<? super K>,V>
-
flush
public void flush()
-
loadInit
protected static <X extends Comparable<? super X>,Y> void loadInit(BSkipSpan<X,Y> bss, BlockFile bf, BSkipList<X,Y> bsl, int spanPage, Serializer<X> key, Serializer<Y> val) throws IOException
I2P - first half of load() Only read the span headers- Throws:
IOException
-
loadData
protected void loadData() throws IOExceptionI2P - second half of load() Load the whole span's keys and values into memory- Throws:
IOException
-
loadData
protected void loadData(boolean flushOnError) throws IOExceptionI2P - second half of load() Load the whole span's keys and values into memory- Parameters:
flushOnError- set to false if you are going to flush anyway- Throws:
IOException
-
lostEntries
protected void lostEntries(int firstBadEntry, int lastGoodPage)Attempt to recover from corrupt data in this span. All entries starting with firstBadEntry are lost. Zero out the overflow page on lastGoodPage, and corect the number of entries in the first page. We don't attempt to free the lost continuation pages.
-
-