Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.metanotion.io.block
Class BlockFile

    java.lang.Object
      net.metanotion.io.block.BlockFile

    public class BlockFile

extends Object

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) 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`
`static 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)`
`BlockFile(RandomAccessFile raf)`
`BlockFile(RandomAccessFile raf, boolean init)`
`BlockFile(RandomAccessInterface rai)`
`BlockFile(RandomAccessInterface rai, boolean init)`

Method Summary
`int` | `allocPage()`
`void` | `bfck(boolean fix)`
`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)`
`static void` | `main(String[] args)`
`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
`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

### PAGESIZE

    public static final int PAGESIZE

See Also:
  Constant Field Values

### OFFSET_MOUNTED

    public static final long OFFSET_MOUNTED

See Also:
  Constant Field Values

### log

    public static final Log log

### file

    public final RandomAccessInterface file

### MAGIC_CONT

    public static final int MAGIC_CONT

See Also:
  Constant Field Values

### METAINDEX_PAGE

    public static final int METAINDEX_PAGE

See Also:
  Constant Field Values

### spanSize

    public int spanSize

Constructor Detail

### BlockFile

    public BlockFile(RandomAccessInterface rai)
              throws IOException

Throws:
  `IOException`

### BlockFile

    public BlockFile(RandomAccessFile raf)
              throws IOException

Throws:
  `IOException`

### BlockFile

    public BlockFile(RandomAccessFile raf,
                     boolean init)
              throws IOException

Throws:
  `IOException`

### BlockFile

    public BlockFile(File f,
                     boolean init)
              throws IOException

Throws:
  `IOException`

### BlockFile

    public BlockFile(RandomAccessInterface rai,
                     boolean init)
              throws IOException

Throws:
  `IOException`

Method Detail

### main

    public static void main(String[] args)

### writeMultiPageData

    public int writeMultiPageData(byte[] data,
                                  int page,
                                  int[] curPageOff,
                                  int[] nextPage)
                           throws IOException

  Write bytes This will allocate additional continuation pages as necessary.

  Parameters:
    `data` - data to write
    `page` - current page
    `curPageOff` - in (current) and out (new) parameter at index 0
    `nextPage` - in (current) and out (new) parameter at index 0
  Returns:
    current page
  Throws:
    `IOException`

### readMultiPageData

    public int readMultiPageData(byte[] arr,
                                 int page,
                                 int[] curPageOff,
                                 int[] nextPage)
                          throws IOException

  Read bytes

  Parameters:
    `arr` - fill this array fully with data
    `page` - current page
    `curPageOff` - in (current) and out (new) parameter at index 0
    `nextPage` - in (current) and out (new) parameter at index 0
  Returns:
    current page
  Throws:
    `IOException`

### skipMultiPageBytes

    public int skipMultiPageBytes(int length,
                                  int page,
                                  int[] curPageOff,
                                  int[] nextPage)
                           throws IOException

  Skip length bytes The same as readMultiPageData() without returning a result

  Parameters:
    `length` - number of bytes to skip
    `page` - current page
    `curPageOff` - in (current) and out (new) parameter at index 0
    `nextPage` - in (current) and out (new) parameter at index 0
  Returns:
    current page
  Throws:
    `IOException`

### pageSeek

    public static void pageSeek(RandomAccessInterface file,
                                int page)
                         throws IOException

  Go to any page but the superblock. Page 1 is the superblock, must use file.seek(0) to get there.

  Parameters:
    `page` - >= 2
  Throws:
    `IOException`

### allocPage

    public int allocPage()
                  throws IOException

  Throws:
    `IOException`

### freePage

    public void freePage(int page)

  Add the page to the free list. The file is never shrunk. TODO: Reclaim free pages at end of file, or even do a full compaction. Does not throw exceptions; logs on failure.

### getIndex

    public BSkipList getIndex(String name,
                              Serializer key,
                              Serializer val)
                       throws IOException

  Throws:
    `IOException`

### makeIndex

    public BSkipList makeIndex(String name,
                               Serializer key,
                               Serializer val)
                        throws IOException

  Throws:
    `IOException`

### delIndex

    public void delIndex(String name)
                  throws IOException

  Throws:
    `IOException`

### closeIndex

    public void closeIndex(String name)

  Added I2P

### close

    public void close()
               throws IOException

  Note (I2P) Does NOT close the RAF / RAI.

  Throws:
    `IOException`

### bfck

    public void bfck(boolean fix)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD