|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.metanotion.io.block.BlockFile
public class BlockFile
On-disk format: Magic number (6 bytes) Version major/minor (2 bytes) file length (long) free list start (unsigned int) is mounted (unsigned short) 0 = no, 1 = yes span size (unsigned short) block size (unsigned int) Metaindex skiplist is on page 2 Pages are 1 KB and are numbered starting from 1. e.g. the Metaindex skiplist is at offset 1024 bytes
Field Summary | |
---|---|
RandomAccessInterface |
file
|
Log |
log
|
static int |
MAGIC_CONT
|
static int |
METAINDEX_PAGE
|
static long |
OFFSET_MOUNTED
|
static int |
PAGESIZE
|
int |
spanSize
|
Constructor Summary | |
---|---|
BlockFile(File f,
boolean init)
File must be writable |
|
BlockFile(RandomAccessFile raf)
RAF must be writable |
|
BlockFile(RandomAccessFile raf,
boolean init)
RAF must be writable |
|
BlockFile(RandomAccessInterface rai)
Use this constructor with a readonly RAI for a readonly blockfile |
|
BlockFile(RandomAccessInterface rai,
boolean init)
Use this constructor with a readonly RAI and init = false for a readonly blockfile |
Method Summary | |
---|---|
int |
allocPage()
|
boolean |
bfck(boolean fix)
Run an integrity check on the blockfile and all the skiplists in it |
void |
close()
Note (I2P) Does NOT close the RAF / RAI. |
void |
closeIndex(String name)
Added I2P |
void |
delIndex(String name)
|
void |
freePage(int page)
Add the page to the free list. |
BSkipList |
getIndex(String name,
Serializer key,
Serializer val)
If the file is writable, this runs an integrity check and repair on first open. |
static void |
main(String[] args)
Run an integrity check on the blockfile and all the skiplists in it. |
BSkipList |
makeIndex(String name,
Serializer key,
Serializer val)
|
static void |
pageSeek(RandomAccessInterface file,
int page)
Go to any page but the superblock. |
int |
readMultiPageData(byte[] arr,
int page,
int[] curPageOff,
int[] nextPage)
Read bytes |
int |
skipMultiPageBytes(int length,
int page,
int[] curPageOff,
int[] nextPage)
Skip length bytes The same as readMultiPageData() without returning a result |
boolean |
wasMounted()
I2P was the file locked when we opened it? |
int |
writeMultiPageData(byte[] data,
int page,
int[] curPageOff,
int[] nextPage)
Write bytes This will allocate additional continuation pages as necessary. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PAGESIZE
public static final long OFFSET_MOUNTED
public final Log log
public final RandomAccessInterface file
public static final int MAGIC_CONT
public static final int METAINDEX_PAGE
public int spanSize
Constructor Detail |
---|
public BlockFile(RandomAccessInterface rai) throws IOException
IOException
public BlockFile(RandomAccessFile raf) throws IOException
IOException
public BlockFile(RandomAccessFile raf, boolean init) throws IOException
IOException
public BlockFile(File f, boolean init) throws IOException
IOException
public BlockFile(RandomAccessInterface rai, boolean init) throws IOException
IOException
Method Detail |
---|
public static void main(String[] args)
public int writeMultiPageData(byte[] data, int page, int[] curPageOff, int[] nextPage) throws IOException
data
- data to writepage
- current pagecurPageOff
- in (current) and out (new) parameter at index 0nextPage
- in (current) and out (new) parameter at index 0
IOException
public int readMultiPageData(byte[] arr, int page, int[] curPageOff, int[] nextPage) throws IOException
arr
- fill this array fully with datapage
- current pagecurPageOff
- in (current) and out (new) parameter at index 0nextPage
- in (current) and out (new) parameter at index 0
IOException
public int skipMultiPageBytes(int length, int page, int[] curPageOff, int[] nextPage) throws IOException
length
- number of bytes to skippage
- current pagecurPageOff
- in (current) and out (new) parameter at index 0nextPage
- in (current) and out (new) parameter at index 0
IOException
public boolean wasMounted()
public static void pageSeek(RandomAccessInterface file, int page) throws IOException
page
- >= 2
IOException
public int allocPage() throws IOException
IOException
public void freePage(int page)
public BSkipList getIndex(String name, Serializer key, Serializer val) throws IOException
IOException
public BSkipList makeIndex(String name, Serializer key, Serializer val) throws IOException
IOException
public void delIndex(String name) throws IOException
IOException
public void closeIndex(String name)
public void close() throws IOException
close
in interface Closeable
IOException
public boolean bfck(boolean fix)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |