org.exist.storage.btree
Class Paged

java.lang.Object
  extended byorg.exist.storage.btree.Paged
Direct Known Subclasses:
BTree

public abstract class Paged
extends java.lang.Object

Paged is a paged file foundation that is used by the BTree class and its subclasses.


Nested Class Summary
 class Paged.FileHeader
          FileHeader
 class Paged.Page
          Page
static class Paged.PageHeader
           
 
Field Summary
protected static byte DELETED
           
protected static Logger LOG
           
protected static byte OVERFLOW
           
protected static int PAGE_SIZE
           
protected static byte UNUSED
           
 
Constructor Summary
Paged()
           
Paged(java.io.File file)
           
 
Method Summary
 void backupToStream(java.io.OutputStream os)
          Backup the entire contents of the underlying file to an output stream.
 boolean close()
          Close the underlying files.
 void closeAndRemove()
          Completely close down the instance and all underlying resources and caches.
 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.
 boolean exists()
           
 boolean flush()
           
 java.io.File getFile()
          getFile returns the file object for this Paged.
 Paged.FileHeader getFileHeader()
          getFileHeader returns the FileHeader
 short getFileVersion()
           
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.
static int getPageSize()
           
static java.lang.String hexDump(byte[] data)
           
 boolean isOpened()
          Gets the opened attribute of the Paged object
 boolean isReadOnly()
           
 boolean open(short expectedVersion)
           
 void printFreeSpaceList()
          Debug
protected  void reuseDeleted(Paged.Page page)
           
protected  void setFile(java.io.File file)
          setFile sets the file object for this Paged.
static void setPageSize(int pageSize)
           
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, byte[] data)
           
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

LOG

protected static final Logger LOG

DELETED

protected static final byte DELETED
See Also:
Constant Field Values

OVERFLOW

protected static final byte OVERFLOW
See Also:
Constant Field Values

UNUSED

protected static final byte UNUSED
See Also:
Constant Field Values

PAGE_SIZE

protected static int PAGE_SIZE
Constructor Detail

Paged

public Paged()

Paged

public Paged(java.io.File file)
      throws DBException
Method Detail

getFileVersion

public short getFileVersion()

setPageSize

public static final void setPageSize(int pageSize)

getPageSize

public static final int getPageSize()

isReadOnly

public final boolean isReadOnly()

close

public boolean close()
              throws DBException
Close the underlying files.

Returns:
Throws:
DBException

create

public boolean create()
               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 java.io.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:
java.io.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

exists

public boolean exists()

flush

public boolean flush()
              throws DBException
Throws:
DBException

backupToStream

public void backupToStream(java.io.OutputStream os)
                    throws java.io.IOException
Backup the entire contents of the underlying file to an output stream.

Parameters:
os -
Throws:
java.io.IOException

getFile

public final java.io.File getFile()
getFile returns the file object for this Paged.

Returns:
The File

getFileHeader

public Paged.FileHeader getFileHeader()
getFileHeader returns the FileHeader

Returns:
The FileHeader

closeAndRemove

public void closeAndRemove()
Completely close down the instance and all underlying resources and caches.


getFreePage

protected final Paged.Page getFreePage()
                                throws java.io.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:
java.io.IOException - if an Exception occurs

getPage

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

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

isOpened

public boolean isOpened()
Gets the opened attribute of the Paged object

Returns:
The opened value

open

public boolean open(short expectedVersion)
             throws DBException
Throws:
DBException

printFreeSpaceList

public void printFreeSpaceList()
                        throws java.io.IOException
Debug

Throws:
java.io.IOException - Description of the Exception

setFile

protected final void setFile(java.io.File file)
                      throws DBException
setFile sets the file object for this Paged.

Parameters:
file - The File
Throws:
DBException

unlinkPages

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

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

unlinkPages

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

Parameters:
pageNum - Description of the Parameter
Throws:
java.io.IOException - if an Exception occurs

reuseDeleted

protected void reuseDeleted(Paged.Page page)
                     throws java.io.IOException
Throws:
java.io.IOException

writeValue

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

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

writeValue

protected final void writeValue(Paged.Page page,
                                byte[] data)
                         throws java.io.IOException
Throws:
java.io.IOException

writeValue

protected final void writeValue(long page,
                                Value value)
                         throws java.io.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:
java.io.IOException - if an Exception occurs

hexDump

public static java.lang.String hexDump(byte[] data)


<oXygen/> XML Editor provides support for editing and debugging XQuery expressions against the eXist XML Database.