Project JXTA

net.jxta.impl.xindice.core.filer
Class Paged

java.lang.Object
  extended bynet.jxta.impl.xindice.core.filer.Paged
Direct Known Subclasses:
BTree

public abstract class Paged
extends Object

Paged is a paged file foundation that is used by both the BTree class and the HashFiler. It provides flexible paged I/O and page caching functionality.


Nested Class Summary
 class Paged.FileHeader
          FileHeader
 class Paged.Page
          Page
 class Paged.PageHeader
          PageHeader
 
Field Summary
protected static byte DELETED
           
protected static int NO_PAGE
           
protected static byte OVERFLOW
           
protected  boolean sync
           
protected static byte UNUSED
           
 
Constructor Summary
Paged()
           
Paged(File file)
           
 
Method Summary
protected  void checkOpened()
           
 boolean close()
           
protected  void closeDescriptor(RandomAccessFile raf)
          Closes a RandomAccessFile ('descriptor') and removes it from the pool.
 boolean create()
           
abstract  Paged.FileHeader createFileHeader()
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
abstract  Paged.FileHeader createFileHeader(boolean read)
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
abstract  Paged.FileHeader createFileHeader(long pageCount)
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
abstract  Paged.FileHeader createFileHeader(long pageCount, int pageSize)
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
abstract  Paged.PageHeader createPageHeader()
          createPageHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a PageHeader.
static int[] deleteArrayInt(int[] vals, int idx)
           
static long[] deleteArrayLong(long[] vals, int idx)
           
static short[] deleteArrayShort(short[] vals, int idx)
           
static Value[] deleteArrayValue(Value[] vals, int idx)
           
 boolean drop()
           
 boolean exists()
           
 void flush()
           
protected  RandomAccessFile getDescriptor()
           
protected  File getFile()
          getFile returns the file object for this Paged.
 Paged.FileHeader getFileHeader()
          getFileHeader returns the FileHeader
protected  Paged.Page getFreePage()
          getFreePage returns the first free Page from secondary storage.
protected  Paged.Page getPage(long pageNum)
          getPage returns the page specified by pageNum.
protected  Paged.Page getPage(Long lp)
          getPage returns the page specified by pageNum.
static int[] insertArrayInt(int[] vals, int val, int idx)
           
static long[] insertArrayLong(long[] vals, long val, int idx)
           
static short[] insertArrayShort(short[] vals, short val, int idx)
           
static Value[] insertArrayValue(Value[] vals, Value val, int idx)
           
 boolean isOpened()
           
 boolean open()
           
protected  void putDescriptor(RandomAccessFile raf)
          Puts a RandomAccessFile ('descriptor') back into the descriptor pool.
protected  Value readValue(long page)
          readValue reads the multi-Paged Value starting at the specified page number.
protected  Value readValue(Paged.Page page)
          readValue reads the multi-Paged Value starting at the specified Page.
protected  void setFile(File file)
          setFile sets the file object for this Paged.
protected  void unlinkPages(long pageNum)
          unlinkPages unlinks a set of pages starting at the specified page number.
protected  void unlinkPages(Paged.Page page)
          unlinkPages unlinks a set of pages starting at the specified Page.
protected  void writeValue(long page, Value value)
          writeValue writes the multi-Paged Value starting at the specified page number.
protected  void writeValue(Paged.Page page, Value value)
          writeValue writes the multi-Paged Value starting at the specified Page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNUSED

protected static final byte UNUSED
See Also:
Constant Field Values

OVERFLOW

protected static final byte OVERFLOW
See Also:
Constant Field Values

DELETED

protected static final byte DELETED
See Also:
Constant Field Values

NO_PAGE

protected static final int NO_PAGE
See Also:
Constant Field Values

sync

protected boolean sync
Constructor Detail

Paged

public Paged()

Paged

public Paged(File file)
Method Detail

setFile

protected final void setFile(File file)
setFile sets the file object for this Paged.

Parameters:
file - The File

getFile

protected final File getFile()
getFile returns the file object for this Paged.

Returns:
The File

getDescriptor

protected final RandomAccessFile getDescriptor()
                                        throws IOException
Throws:
IOException

putDescriptor

protected final void putDescriptor(RandomAccessFile raf)
Puts a RandomAccessFile ('descriptor') back into the descriptor pool.


closeDescriptor

protected final void closeDescriptor(RandomAccessFile raf)
Closes a RandomAccessFile ('descriptor') and removes it from the pool.


getPage

protected final Paged.Page getPage(Long lp)
                            throws IOException
getPage returns the page specified by pageNum.

Parameters:
lp - The Page number
Returns:
The requested Page
Throws:
IOException - if an Exception occurs

getPage

protected final Paged.Page getPage(long pageNum)
                            throws IOException
getPage returns the page specified by pageNum.

Parameters:
pageNum - The Page number
Returns:
The requested Page
Throws:
IOException - if an Exception occurs

readValue

protected final Value readValue(Paged.Page page)
                         throws IOException
readValue reads the multi-Paged Value starting at the specified Page.

Parameters:
page - The starting Page
Returns:
The Value
Throws:
IOException - if an Exception occurs

readValue

protected final Value readValue(long page)
                         throws IOException
readValue reads the multi-Paged Value starting at the specified page number.

Parameters:
page - The starting page number
Returns:
The Value
Throws:
IOException - if an Exception occurs

writeValue

protected final void writeValue(Paged.Page page,
                                Value value)
                         throws IOException
writeValue writes the multi-Paged Value starting at the specified Page.

Parameters:
page - The starting Page
value - The Value to write
Throws:
IOException - if an Exception occurs

writeValue

protected final void writeValue(long page,
                                Value value)
                         throws IOException
writeValue writes the multi-Paged Value starting at the specified page number.

Parameters:
page - The starting page number
value - The Value to write
Throws:
IOException - if an Exception occurs

unlinkPages

protected final void unlinkPages(Paged.Page page)
                          throws IOException
unlinkPages unlinks a set of pages starting at the specified Page.

Parameters:
page - The starting Page to unlink
Throws:
IOException - if an Exception occurs

unlinkPages

protected final void unlinkPages(long pageNum)
                          throws IOException
unlinkPages unlinks a set of pages starting at the specified page number.

Parameters:
pageNum - The starting page number to unlink
Throws:
IOException - if an Exception occurs

getFreePage

protected final Paged.Page getFreePage()
                                throws IOException
getFreePage returns the first free Page from secondary storage. If no Pages are available, the file is grown as appropriate.

Returns:
The next free Page
Throws:
IOException - if an Exception occurs

checkOpened

protected final void checkOpened()
                          throws DBException
Throws:
DBException

getFileHeader

public Paged.FileHeader getFileHeader()
getFileHeader returns the FileHeader

Returns:
The FileHeader

exists

public boolean exists()

create

public boolean create()
               throws DBException
Throws:
DBException

open

public boolean open()
             throws DBException
Throws:
DBException

close

public boolean close()
              throws DBException
Throws:
DBException

isOpened

public boolean isOpened()

drop

public boolean drop()
             throws DBException
Throws:
DBException

flush

public void flush()
           throws DBException
Throws:
DBException

createFileHeader

public abstract Paged.FileHeader createFileHeader()
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.

Returns:
a new FileHeader

createFileHeader

public abstract Paged.FileHeader createFileHeader(boolean read)
                                           throws IOException
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.

Parameters:
read - If true, reads the FileHeader from disk
Returns:
a new FileHeader
Throws:
IOException - if an exception occurs

createFileHeader

public abstract Paged.FileHeader createFileHeader(long pageCount)
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.

Parameters:
pageCount - The number of pages to allocate for primary storage
Returns:
a new FileHeader

createFileHeader

public abstract Paged.FileHeader createFileHeader(long pageCount,
                                                  int pageSize)
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.

Parameters:
pageCount - The number of pages to allocate for primary storage
pageSize - The size of a Page (should be a multiple of a FS block)
Returns:
a new FileHeader

createPageHeader

public abstract Paged.PageHeader createPageHeader()
createPageHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a PageHeader.

Returns:
a new PageHeader

insertArrayValue

public static Value[] insertArrayValue(Value[] vals,
                                       Value val,
                                       int idx)

deleteArrayValue

public static Value[] deleteArrayValue(Value[] vals,
                                       int idx)

insertArrayLong

public static long[] insertArrayLong(long[] vals,
                                     long val,
                                     int idx)

deleteArrayLong

public static long[] deleteArrayLong(long[] vals,
                                     int idx)

insertArrayInt

public static int[] insertArrayInt(int[] vals,
                                   int val,
                                   int idx)

deleteArrayInt

public static int[] deleteArrayInt(int[] vals,
                                   int idx)

insertArrayShort

public static short[] insertArrayShort(short[] vals,
                                       short val,
                                       int idx)

deleteArrayShort

public static short[] deleteArrayShort(short[] vals,
                                       int idx)

JXTA J2SE