## net.metanotion.io.block.index
Class BSkipSpan

    java.lang.Object
      net.metanotion.util.skiplist.SkipSpan
          net.metanotion.io.block.index.BSkipSpan

Direct Known Subclasses:
  IBSkipSpan

    public class BSkipSpan

extends SkipSpan

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
`protected BlockFile` `bf`
`static int` `CONT_HEADER_LEN`
`protected static int` `HEADER_LEN`
`protected boolean` `isKilled`
`protected Serializer` `keySer`
`protected static int` `MAGIC`
`protected int` `nextPage`
`protected int` `overflowPage`
`protected int` `page`
`protected int` `prevPage`
`protected int` `spanSize`
`protected Serializer` `valSer`

Fields inherited from class net.metanotion.util.skiplist.SkipSpan
`keys, MAX_SIZE, next, nKeys, prev, vals`

Constructor Summary
`protected` `BSkipSpan(BlockFile bf, BSkipList bsl)`
`` `BSkipSpan(BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val)`

Method Summary
`void` `flush()`
`static void` `init(BlockFile bf, int page, int spanSize)`
`void` `killInstance()`
`protected void` `loadData()` I2P - second half of load() Load the whole span's keys and values into memory
`protected void` `loadData(boolean flushOnError)` I2P - second half of load() Load the whole span's keys and values into memory
`protected static void` `loadInit(BSkipSpan bss, BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val)` I2P - first half of load() Only read the span headers
`protected void` `lostEntries(int firstBadEntry, int lastGoodPage)` Attempt to recover from corrupt data in this span.
`SkipSpan` `newInstance(SkipList sl)`
`String` `toString()`

Methods inherited from class net.metanotion.util.skiplist.SkipSpan
`firstKey, get, getEnd, getSpan, print, put, remove`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

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 keySer

### valSer

    protected Serializer valSer

### spanSize

    protected int spanSize

### isKilled

    protected boolean isKilled

Constructor Detail

### BSkipSpan

    protected BSkipSpan(BlockFile bf,
                        BSkipList bsl)

### BSkipSpan

    public BSkipSpan(BlockFile bf,
                     BSkipList bsl,
                     int spanPage,
                     Serializer key,
                     Serializer 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 newInstance(SkipList sl)

  Overrides:
    `newInstance` in class `SkipSpan`

### killInstance

    public void killInstance()

  Overrides:
    `killInstance` in class `SkipSpan`

### flush

    public void flush()

  Overrides:
    `flush` in class `SkipSpan`

### loadInit

    protected static void loadInit(BSkipSpan bss,
                                   BlockFile bf,
                                   BSkipList bsl,
                                   int spanPage,
                                   Serializer key,
                                   Serializer val)
                            throws IOException

  I2P - first half of load() Only read the span headers

  Throws:
    `IOException`

### loadData

    protected void loadData()
                     throws IOException

  I2P - second half of load() Load the whole span's keys and values into memory

  Throws:
    `IOException`

### loadData

    protected void loadData(boolean flushOnError)
                     throws IOException

  I2P - 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.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`