JXTA

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

java.lang.Object
  extended by net.jxta.impl.xindice.core.filer.Paged
      extended by net.jxta.impl.xindice.core.filer.BTree
          extended by net.jxta.impl.xindice.core.filer.BTreeFiler
All Implemented Interfaces:
DBObject, Filer, Named

public final class BTreeFiler
extends BTree
implements Filer

BTreeFiler is a Filer implementation based on the BTree class.


Nested Class Summary
 
Nested classes/interfaces inherited from class net.jxta.impl.xindice.core.filer.BTree
BTree.BTreeFileHeader, BTree.BTreePageHeader, BTree.BTreeRootInfo
 
Nested classes/interfaces inherited from class net.jxta.impl.xindice.core.filer.Paged
Paged.FileHeader, Paged.Page, Paged.PageHeader
 
Field Summary
protected static byte RECORD
           
 
Fields inherited from class net.jxta.impl.xindice.core.filer.BTree
BRANCH, LEAF, STREAM
 
Fields inherited from class net.jxta.impl.xindice.core.filer.Paged
DELETED, NO_PAGE, OVERFLOW, sync, UNUSED
 
Constructor Summary
BTreeFiler()
           
 
Method Summary
 boolean create()
          create creates a new DBObject and any associated resources for the new DBObject, such as disk files, etc.
 Paged.FileHeader createFileHeader()
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
 Paged.FileHeader createFileHeader(boolean read)
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
 Paged.FileHeader createFileHeader(long pageCount)
          createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.
 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.
 Paged.PageHeader createPageHeader()
          createPageHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a PageHeader.
 boolean deleteRecord(Key key)
          deleteRecord removes a Record from the Filer based on the specified Key.
 String getName()
          getName retrieves the contextually important name of the object
 long getRecordCount()
          getRecordCount returns the number of Records in the Filer.
 RecordSet getRecordSet()
          getRecordSet returns a RecordSet object for the current Filer.
 boolean open()
          open opens the DBObject
 Record readRecord(Key key)
          readRecord returns a Record from the Filer based on the specified Key.
 Record readRecord(long pos)
          readRecord returns a Record from the Filer at the specified position.
 void setLocation(String dir, String file)
           
 long writeRecord(Key key, Value value)
          writeRecord writes a Value to the Filer based on the specified Key.
 long writeRecord(Key key, Value value, long lifetime, long expiration)
           
 long writeRecord(long pos, Value value)
           
 
Methods inherited from class net.jxta.impl.xindice.core.filer.BTree
addValue, addValue, createBTreeRoot, createBTreeRoot, findBTreeRoot, findBTreeRoot, findValue, findValue, getRootNode, getRootNode, query, query, removeValue, removeValue, setRootNode, setRootNode, setSync
 
Methods inherited from class net.jxta.impl.xindice.core.filer.Paged
addDirty, checkOpened, close, closeDescriptor, deleteArrayInt, deleteArrayLong, deleteArrayShort, deleteArrayValue, drop, exists, flush, getDescriptor, getFile, getFileHeader, getFreePage, getPage, insertArrayInt, insertArrayLong, insertArrayShort, insertArrayValue, isOpened, putDescriptor, readValue, readValue, setFile, unlinkPages, unlinkPages, writeValue, writeValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.jxta.impl.xindice.core.filer.Filer
flush
 
Methods inherited from interface net.jxta.impl.xindice.core.DBObject
close, drop, exists, isOpened
 

Field Detail

RECORD

protected static final byte RECORD
See Also:
Constant Field Values
Constructor Detail

BTreeFiler

public BTreeFiler()
Method Detail

setLocation

public void setLocation(String dir,
                        String file)

getName

public String getName()
Description copied from interface: Named
getName retrieves the contextually important name of the object

Specified by:
getName in interface Named
Returns:
The object's name

open

public boolean open()
             throws DBException
Description copied from interface: DBObject
open opens the DBObject

Specified by:
open in interface DBObject
Overrides:
open in class BTree
Returns:
Whether or not the DBObject was opened
Throws:
DBException - if a DB error occurs

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
Overrides:
create in class BTree
Returns:
Whether or not the DBObject was created
Throws:
DBException - if a DB error occurs

readRecord

public Record readRecord(Key key)
                  throws DBException
Description copied from interface: Filer
readRecord returns a Record from the Filer based on the specified Key.

Specified by:
readRecord in interface Filer
Parameters:
key - The Record's Key
Returns:
The returned Record
Throws:
DBException - if a db exception occurs

readRecord

public Record readRecord(long pos)
                  throws DBException
Description copied from interface: Filer
readRecord returns a Record from the Filer at the specified position. The Record's Key will be set to null.

Specified by:
readRecord in interface Filer
Parameters:
pos - The Record's position
Returns:
The returned Record
Throws:
DBException - if a db exception occurs

writeRecord

public long writeRecord(Key key,
                        Value value)
                 throws DBException
Description copied from interface: Filer
writeRecord writes a Value to the Filer based on the specified Key.

Specified by:
writeRecord in interface Filer
Parameters:
key - The Record's Key
value - The Record's Value
Returns:
0 if the Record could not be written, the starting offset of the Record otherwise (used for indexing)
Throws:
DBException - if a db exception occurs

writeRecord

public long writeRecord(Key key,
                        Value value,
                        long lifetime,
                        long expiration)
                 throws DBException
Throws:
DBException

writeRecord

public long writeRecord(long pos,
                        Value value)
                 throws DBException
Throws:
DBException

deleteRecord

public boolean deleteRecord(Key key)
                     throws DBException
Description copied from interface: Filer
deleteRecord removes a Record from the Filer based on the specified Key.

Specified by:
deleteRecord in interface Filer
Parameters:
key - The Record's Key
Returns:
Whether or not the Record was deleted
Throws:
DBException - if a db exception occurs

getRecordCount

public long getRecordCount()
                    throws DBException
Description copied from interface: Filer
getRecordCount returns the number of Records in the Filer.

Specified by:
getRecordCount in interface Filer
Returns:
The Record count
Throws:
DBException - if a db exception occurs

getRecordSet

public RecordSet getRecordSet()
                       throws DBException
Description copied from interface: Filer
getRecordSet returns a RecordSet object for the current Filer.

Specified by:
getRecordSet in interface Filer
Returns:
The Filer Enumerator
Throws:
DBException - if a db exception occurs

createFileHeader

public Paged.FileHeader createFileHeader()
Description copied from class: Paged
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader.

Overrides:
createFileHeader in class BTree
Returns:
a new FileHeader

createFileHeader

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

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

createFileHeader

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

Overrides:
createFileHeader in class BTree
Parameters:
pageCount - The number of pages to allocate for primary storage
Returns:
a new FileHeader

createFileHeader

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

Overrides:
createFileHeader in class BTree
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 Paged.PageHeader createPageHeader()
Description copied from class: Paged
createPageHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a PageHeader.

Overrides:
createPageHeader in class BTree
Returns:
a new PageHeader

JXSE