Xindice API
version 1.1b4

org.apache.xindice.core.filer
Class Paged

java.lang.Object
  |
  +--org.apache.xindice.core.filer.Paged
All Implemented Interfaces:
Configurable, DBObject
Direct Known Subclasses:
BTree, HashFiler

public abstract class Paged
extends java.lang.Object
implements DBObject, Configurable

Paged is a paged file implementation that is foundation for both the BTree class and the HashFiler. It provides flexible paged I/O and page caching functionality. Page has folowing configuration attributes:

FIXME: Currently it seems that maxkeysize is not used anywhere.

Version:
CVS $Revision: 1.29 $, $Date: 2004/03/20 14:02:38 $

Inner Class Summary
 class Paged.FileHeader
          Paged file's header
 class Paged.Page
          Paged file's page
static class Paged.PageHeader
          Paged file page's header
 
Field Summary
protected static byte DELETED
          Deleted page status
protected static int NO_PAGE
          Page ID of non-existent page
protected static byte OVERFLOW
          Overflow page status
protected static byte UNUSED
          Unused page status
 
Constructor Summary
Paged()
           
Paged(java.io.File file)
           
 
Method Summary
protected  void checkOpened()
           
 boolean close()
          close closes the DBObject
protected  void closeDescriptor(java.io.RandomAccessFile raf)
          Closes a RandomAccessFile ('descriptor') and removes it from the pool.
 boolean create()
          create creates a new DBObject and any associated resources for the new DBObject, such as disk files, etc.
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()
          drop instructs the DBObjectimplementation to remove itself from existence.
 boolean exists()
          exists returns whether or not a physical representation of this DBObject actually exists.
 void flush()
           
 Configuration getConfig()
          getConfig retrieves the configuration information for the Configurable object instance.
protected  java.io.RandomAccessFile getDescriptor()
          Obtain RandomAccessFile ('descriptor') object out of the pool.
protected  java.io.File getFile()
          getFile returns the file object for this Paged.
protected  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.
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()
          isOpened returns whether or not the DBObject is opened for business.
 boolean open()
          open opens the DBObject
protected  void putDescriptor(java.io.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.
 void setConfig(Configuration config)
          setConfig sets the configuration information for the Configurable object instance.
protected  void setFile(java.io.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
Unused page status

OVERFLOW

protected static final byte OVERFLOW
Overflow page status

DELETED

protected static final byte DELETED
Deleted page status

NO_PAGE

protected static final int NO_PAGE
Page ID of non-existent page
Constructor Detail

Paged

public Paged()

Paged

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

setConfig

public void setConfig(Configuration config)
Description copied from interface: Configurable
setConfig sets the configuration information for the Configurable object instance.
Specified by:
setConfig in interface Configurable
Following copied from interface: org.apache.xindice.util.Configurable
Parameters:
config - The configuration Node

getConfig

public Configuration getConfig()
Description copied from interface: Configurable
getConfig retrieves the configuration information for the Configurable object instance.
Specified by:
getConfig in interface Configurable
Following copied from interface: org.apache.xindice.util.Configurable
Returns:
The configuration Node

setFile

protected final void setFile(java.io.File file)
setFile sets the file object for this Paged.
Parameters:
file - The File

getFile

protected final java.io.File getFile()
getFile returns the file object for this Paged.
Returns:
The File

getDescriptor

protected final java.io.RandomAccessFile getDescriptor()
                                                throws java.io.IOException
Obtain RandomAccessFile ('descriptor') object out of the pool. If no descriptors available, and maximum amount already allocated, the call will block.

putDescriptor

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

closeDescriptor

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

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

readValue

protected final Value readValue(Paged.Page page)
                         throws java.io.IOException
readValue reads the multi-Paged Value starting at the specified Page.
Parameters:
page - The starting Page
Returns:
The Value
Throws:
java.io.IOException - if an Exception occurs

readValue

protected final Value readValue(long page)
                         throws java.io.IOException
readValue reads the multi-Paged Value starting at the specified page number.
Parameters:
page - The starting page number
Returns:
The Value
Throws:
java.io.IOException - if an Exception occurs

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(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

unlinkPages

protected final 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 - The starting page number to unlink
Throws:
java.io.IOException - if an Exception occurs

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

checkOpened

protected final void checkOpened()
                          throws DBException
Throws:
DBException - COL_COLLECTION_CLOSED if paged file is closed

getFileHeader

protected Paged.FileHeader getFileHeader()
getFileHeader returns the FileHeader
Returns:
The FileHeader

exists

public boolean exists()
Description copied from interface: DBObject
exists returns whether or not a physical representation of this DBObject actually exists. In the case of a HashFiler, this would check for the file, and in the case of an FTPFiler, it might perform a connection check.
Specified by:
exists in interface DBObject
Returns:
True if this paged file exists

create

public boolean create()
               throws DBException
Description copied from interface: DBObject
create creates a new DBObject and any associated resources for the new DBObject, such as disk files, etc.
Specified by:
create in interface DBObject
Following copied from interface: org.apache.xindice.core.DBObject
Returns:
Whether or not the DBObject was created

open

public boolean open()
             throws DBException
Description copied from interface: DBObject
open opens the DBObject
Specified by:
open in interface DBObject
Following copied from interface: org.apache.xindice.core.DBObject
Returns:
Whether or not the DBObject was opened

close

public boolean close()
              throws DBException
Description copied from interface: DBObject
close closes the DBObject
Specified by:
close in interface DBObject
Following copied from interface: org.apache.xindice.core.DBObject
Returns:
Whether or not the DBObject was closed

isOpened

public boolean isOpened()
Description copied from interface: DBObject
isOpened returns whether or not the DBObject is opened for business.
Specified by:
isOpened in interface DBObject
Following copied from interface: org.apache.xindice.core.DBObject
Returns:
The open status of the DBObject

drop

public boolean drop()
             throws DBException
Description copied from interface: DBObject
drop instructs the DBObjectimplementation to remove itself from existence. The DBObject's parent is responsible for removing any references to the DBObject in its own context.
Specified by:
drop in interface DBObject
Following copied from interface: org.apache.xindice.core.DBObject
Returns:
Whether or not the DBObject was dropped

flush

public void flush()
           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

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)

Xindice API
version 1.1b4

Copyright (c) 1999-2004 The Apache Software Foundation. All Rights Reserved.