K - type of keys maintained by this skip listV - type of mapped valuespublic class BSkipList<K extends Comparable<? super K>,V> extends SkipList<K,V> implements Closeable
Provides efficient indexed storage with logarithmic search performance. Supports multiple spans and levels for scalable data organization.
On-disk format:
Magic number (long)
first span page (unsigned int)
first level page (unsigned int)
size (unsigned int)
spans (unsigned int)
levels (unsigned int)
Always fits on one page.
| Modifier and Type | Field and Description |
|---|---|
BlockFile |
bf
Reference to the BlockFile
|
int |
firstLevelPage
Page number of the first level
|
int |
firstSpanPage
Page number of the first span
|
(package private) HashMap<Integer,SkipLevels<K,V>> |
levelHash |
int |
skipPage
Page number of this skiplist header
|
(package private) HashMap<Integer,BSkipSpan<K,V>> |
spanHash |
| Constructor and Description |
|---|
BSkipList(int spanSize,
BlockFile bf,
int skipPage,
Serializer<K> key,
Serializer<V> val)
Create a BSkipList from a BlockFile.
|
BSkipList(int spanSize,
BlockFile bf,
int skipPage,
Serializer<K> key,
Serializer<V> val,
boolean fileOnly)
Create a BSkipList from a BlockFile.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
bslck(boolean fix,
boolean isMeta)
Run an integrity check on the skiplist and all the levels in it.
|
void |
close()
Close this skiplist and flush all data to disk.
|
void |
delete()
Delete this skiplist and free all its pages.
|
SkipIterator<K,V> |
find(K key)
Find the entry with the given key.
|
void |
flush()
Flush all data to disk.
|
static void |
init(BlockFile bf,
int page,
int spanSize)
Initialize a new skiplist on disk.
|
SkipIterator<K,V> |
iterator()
Get an iterator over all entries in this skiplist.
|
int |
maxLevels()
Calculate the maximum number of levels for this skiplist.
|
String |
toString()
Get a string representation of this skiplist.
|
addItem, balance, delItem, generateColHeight, get, put, remove, sizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic final BlockFile bf
public int firstLevelPage
public int firstSpanPage
final HashMap<Integer,SkipLevels<K extends Comparable<? super K>,V>> levelHash
public int skipPage
public BSkipList(int spanSize,
BlockFile bf,
int skipPage,
Serializer<K> key,
Serializer<V> val)
throws IOException
spanSize - the size of spansbf - the BlockFileskipPage - the page number of this skiplistkey - the key serializerval - the value serializerIOException - if an I/O error occurspublic BSkipList(int spanSize,
BlockFile bf,
int skipPage,
Serializer<K> key,
Serializer<V> val,
boolean fileOnly)
throws IOException
spanSize - the size of spansbf - the BlockFileskipPage - the page number of this skiplistkey - the key serializerval - the value serializerfileOnly - if true, only read from file (no caching)IOException - if an I/O error occurspublic boolean bslck(boolean fix,
boolean isMeta)
fix - if true, attempt to fix any corruption foundisMeta - if true, this is a metaindex skiplistpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void delete()
throws IOException
IOException - if an I/O error occurspublic SkipIterator<K,V> find(K key)
public void flush()
public static void init(BlockFile bf, int page, int spanSize) throws IOException
bf - the BlockFilepage - the page number for the skiplist headerspanSize - the span size to useIOException - if an I/O error occurspublic SkipIterator<K,V> iterator()
public int maxLevels()