org.exist.storage.store
Class BFile

java.lang.Object
  extended byorg.dbxml.core.filer.Paged
      extended byorg.dbxml.core.filer.BTree
          extended byorg.exist.storage.store.BFile
Direct Known Subclasses:
CollectionStore

public class BFile
extends org.dbxml.core.filer.BTree

Data store for variable size values. This class maps keys to values of variable size. Keys are stored in the b+-tree. B+-tree values are pointers to the logical storage address of the value in the data section. The pointer consists of the page number and a logical tuple identifier. If a value is larger than the internal page size (4K), it is split into overflow pages. Appending data to a overflow page is very fast. Only the first and the last data page are loaded. Data pages are buffered.

Author:
Wolfgang Meier

Nested Class Summary
protected  class BFile.ClockPageBuffer
           
static interface BFile.PageInputStream
           
 
Nested classes inherited from class org.dbxml.core.filer.BTree
org.dbxml.core.filer.BTree.BTreeFileHeader, org.dbxml.core.filer.BTree.BTreeNode, org.dbxml.core.filer.BTree.BTreePageHeader, org.dbxml.core.filer.BTree.ClockNodeBuffer
 
Nested classes inherited from class org.dbxml.core.filer.Paged
org.dbxml.core.filer.Paged.FileHeader, org.dbxml.core.filer.Paged.Page, org.dbxml.core.filer.Paged.PageHeader
 
Field Summary
protected  boolean compressPages
           
protected  org.exist.storage.store.BFile.BFileHeader fileHeader
           
 int fixedKeyLen
           
static byte FREE_LIST
          Description of the Field
static byte LOB
          Description of the Field
protected  Lock lock
           
protected  int minFree
           
static byte MULTI_PAGE
          Description of the Field
static int PAGE_MIN_FREE
           
protected  BFile.ClockPageBuffer pages
           
static byte RECORD
           
 
Fields inherited from class org.dbxml.core.filer.BTree
BRANCH, KEY_NOT_FOUND, LEAF, STREAM
 
Fields inherited from class org.dbxml.core.filer.Paged
DELETED, OVERFLOW, PAGE_SIZE, UNUSED
 
Constructor Summary
BFile()
          Constructor for the BFile object
BFile(java.io.File file)
          Constructor for the BFile object
BFile(java.io.File file, int buffers)
          Constructor for the BFile object
BFile(java.io.File file, int btreeBuffers, int dataBuffers)
          Constructor for the BFile object
 
Method Summary
 long append(org.dbxml.core.data.Value key, ByteArray value)
           
 boolean close()
          Description of the Method
 boolean containsKey(org.dbxml.core.data.Value key)
          Description of the Method
 boolean create()
          Description of the Method
 org.dbxml.core.filer.Paged.FileHeader createFileHeader()
          Description of the Method
 org.dbxml.core.filer.Paged.FileHeader createFileHeader(boolean read)
          Description of the Method
 org.dbxml.core.filer.Paged.FileHeader createFileHeader(long pageCount)
          Description of the Method
 org.dbxml.core.filer.Paged.FileHeader createFileHeader(long pageCount, int pageSize)
          Description of the Method
 org.dbxml.core.filer.Paged.PageHeader createPageHeader()
          Description of the Method
 void filter(org.dbxml.core.indexer.IndexQuery query, BFileCallback callback)
          Description of the Method
 void find(org.dbxml.core.indexer.IndexQuery query, IndexCallback callback)
           
 java.util.ArrayList findEntries(org.dbxml.core.indexer.IndexQuery query)
          Description of the Method
 java.util.ArrayList findKeys(org.dbxml.core.indexer.IndexQuery query)
          Description of the Method
 java.util.ArrayList findValues(org.dbxml.core.indexer.IndexQuery query)
           
 boolean flush()
           
protected  org.dbxml.core.data.Value get(org.exist.storage.store.BFile.DataPage page, long p)
          Retrieve value at logical address p from page
 org.dbxml.core.data.Value get(long p)
          Description of the Method
 org.dbxml.core.data.Value get(org.dbxml.core.data.Value key)
           
 java.io.InputStream getAsStream(long pointer)
           
 java.io.InputStream getAsStream(org.dbxml.core.data.Value key)
           
 BufferStats getDataBufferStats()
           
 java.util.ArrayList getEntries()
          Gets the entries attribute of the BFile object
 java.util.ArrayList getKeys()
          Gets the keys attribute of the BFile object
 Lock getLock()
          Returns the Lock object responsible for this BFile.
 java.util.ArrayList getValues()
          Gets the values attribute of the BFile object
 int getValueSize(org.dbxml.core.data.Value key)
           
 boolean open()
          Description of the Method
 void printStatistics()
           
 long put(org.dbxml.core.data.Value key, byte[] data, boolean overwrite)
           
 long put(org.dbxml.core.data.Value key, ByteArray value)
          Description of the Method
 long put(org.dbxml.core.data.Value key, ByteArray value, boolean overwrite)
          Description of the Method
protected  void remove(org.exist.storage.store.BFile.DataPage page, long p)
          Description of the Method
 void remove(long p)
           
 void remove(org.dbxml.core.data.Value key)
          Description of the Method
 void removeAll(org.dbxml.core.indexer.IndexQuery query)
           
 void setCompression(boolean compress)
          Sets the compression attribute of the BFile object
 void setLocation(java.lang.String location)
          Sets the location attribute of the BFile object
protected  long update(long p, org.exist.storage.store.BFile.DataPage page, org.dbxml.core.data.Value key, ByteArray value)
          Update the key/value pair with logical address p and stored in page.
 long update(long p, org.dbxml.core.data.Value key, ByteArray value)
          Update the key/value pair found at the logical address p.
 long update(org.dbxml.core.data.Value key, ByteArray value)
          Update a key/value pair.
 
Methods inherited from class org.dbxml.core.filer.BTree
addValue, clear, create, createRootNode, drop, findValue, getFixedKeyLen, getIndexBufferStats, getRootNode, query, remove, remove, removeValue, setRootNode
 
Methods inherited from class org.dbxml.core.filer.Paged
deleteArrayInt, deleteArrayLong, deleteArrayShort, deleteArrayValue, exists, getFile, getFileHeader, getFreePage, getPage, getPageSize, insertArrayInt, insertArrayLong, insertArrayShort, insertArrayValue, isOpened, isReadOnly, setFile, setPageSize, unlinkPages, unlinkPages, writeValue, writeValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FREE_LIST

public static final byte FREE_LIST
Description of the Field

See Also:
Constant Field Values

LOB

public static final byte LOB
Description of the Field

See Also:
Constant Field Values

MULTI_PAGE

public static final byte MULTI_PAGE
Description of the Field

See Also:
Constant Field Values

PAGE_MIN_FREE

public static final int PAGE_MIN_FREE
See Also:
Constant Field Values

RECORD

public static final byte RECORD
See Also:
Constant Field Values

compressPages

protected boolean compressPages

fileHeader

protected org.exist.storage.store.BFile.BFileHeader fileHeader

minFree

protected int minFree

pages

protected BFile.ClockPageBuffer pages

lock

protected Lock lock

fixedKeyLen

public int fixedKeyLen
Constructor Detail

BFile

public BFile()
Constructor for the BFile object


BFile

public BFile(java.io.File file)
Constructor for the BFile object

Parameters:
file - Description of the Parameter

BFile

public BFile(java.io.File file,
             int buffers)
Constructor for the BFile object

Parameters:
file - Description of the Parameter
buffers - Description of the Parameter

BFile

public BFile(java.io.File file,
             int btreeBuffers,
             int dataBuffers)
Constructor for the BFile object

Parameters:
file - Description of the Parameter
btreeBuffers - Description of the Parameter
dataBuffers - Description of the Parameter
Method Detail

getLock

public Lock getLock()
Returns the Lock object responsible for this BFile.

Returns:
Lock

append

public long append(org.dbxml.core.data.Value key,
                   ByteArray value)
            throws ReadOnlyException
Throws:
ReadOnlyException

close

public boolean close()
              throws org.dbxml.core.DBException
Description of the Method

Returns:
Description of the Return Value
Throws:
org.dbxml.core.DBException - Description of the Exception

containsKey

public boolean containsKey(org.dbxml.core.data.Value key)
Description of the Method

Parameters:
key - Description of the Parameter
Returns:
Description of the Return Value

create

public boolean create()
               throws org.dbxml.core.DBException
Description of the Method

Returns:
Description of the Return Value
Throws:
org.dbxml.core.DBException - Description of the Exception

createFileHeader

public org.dbxml.core.filer.Paged.FileHeader createFileHeader()
Description of the Method

Returns:
Description of the Return Value

createFileHeader

public org.dbxml.core.filer.Paged.FileHeader createFileHeader(boolean read)
                                                       throws java.io.IOException
Description of the Method

Parameters:
read - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

createFileHeader

public org.dbxml.core.filer.Paged.FileHeader createFileHeader(long pageCount)
Description of the Method

Parameters:
pageCount - Description of the Parameter
Returns:
Description of the Return Value

createFileHeader

public org.dbxml.core.filer.Paged.FileHeader createFileHeader(long pageCount,
                                                              int pageSize)
Description of the Method

Parameters:
pageCount - Description of the Parameter
pageSize - Description of the Parameter
Returns:
Description of the Return Value

createPageHeader

public org.dbxml.core.filer.Paged.PageHeader createPageHeader()
Description of the Method

Returns:
Description of the Return Value

filter

public void filter(org.dbxml.core.indexer.IndexQuery query,
                   BFileCallback callback)
            throws java.io.IOException,
                   org.dbxml.core.filer.BTreeException
Description of the Method

Parameters:
query - Description of the Parameter
callback - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception
org.dbxml.core.filer.BTreeException - Description of the Exception

removeAll

public void removeAll(org.dbxml.core.indexer.IndexQuery query)
               throws java.io.IOException,
                      org.dbxml.core.filer.BTreeException
Throws:
java.io.IOException
org.dbxml.core.filer.BTreeException

findEntries

public java.util.ArrayList findEntries(org.dbxml.core.indexer.IndexQuery query)
                                throws java.io.IOException,
                                       org.dbxml.core.filer.BTreeException
Description of the Method

Parameters:
query - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception
org.dbxml.core.filer.BTreeException - Description of the Exception

findKeys

public java.util.ArrayList findKeys(org.dbxml.core.indexer.IndexQuery query)
                             throws java.io.IOException,
                                    org.dbxml.core.filer.BTreeException
Description of the Method

Parameters:
query - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception
org.dbxml.core.filer.BTreeException - Description of the Exception

find

public void find(org.dbxml.core.indexer.IndexQuery query,
                 IndexCallback callback)
          throws java.io.IOException,
                 org.dbxml.core.filer.BTreeException
Throws:
java.io.IOException
org.dbxml.core.filer.BTreeException

findValues

public java.util.ArrayList findValues(org.dbxml.core.indexer.IndexQuery query)
                               throws java.io.IOException,
                                      org.dbxml.core.filer.BTreeException
Throws:
java.io.IOException
org.dbxml.core.filer.BTreeException

flush

public boolean flush()
              throws org.dbxml.core.DBException
Throws:
org.dbxml.core.DBException

getDataBufferStats

public BufferStats getDataBufferStats()

printStatistics

public void printStatistics()

get

public org.dbxml.core.data.Value get(org.dbxml.core.data.Value key)

getAsStream

public java.io.InputStream getAsStream(org.dbxml.core.data.Value key)

getAsStream

public java.io.InputStream getAsStream(long pointer)

getValueSize

public int getValueSize(org.dbxml.core.data.Value key)

get

public org.dbxml.core.data.Value get(long p)
Description of the Method

Parameters:
p - Description of the Parameter
Returns:
Description of the Return Value

get

protected org.dbxml.core.data.Value get(org.exist.storage.store.BFile.DataPage page,
                                        long p)
                                 throws org.dbxml.core.filer.BTreeException,
                                        java.io.IOException
Retrieve value at logical address p from page

Parameters:
page - Description of the Parameter
p - Description of the Parameter
Returns:
Description of the Return Value
Throws:
org.dbxml.core.filer.BTreeException - Description of the Exception
java.io.IOException - Description of the Exception

getEntries

public java.util.ArrayList getEntries()
                               throws java.io.IOException,
                                      org.dbxml.core.filer.BTreeException
Gets the entries attribute of the BFile object

Returns:
The entries value
Throws:
java.io.IOException - Description of the Exception
org.dbxml.core.filer.BTreeException - Description of the Exception

getKeys

public java.util.ArrayList getKeys()
                            throws java.io.IOException,
                                   org.dbxml.core.filer.BTreeException
Gets the keys attribute of the BFile object

Returns:
The keys value
Throws:
java.io.IOException - Description of the Exception
org.dbxml.core.filer.BTreeException - Description of the Exception

getValues

public java.util.ArrayList getValues()
                              throws java.io.IOException,
                                     org.dbxml.core.filer.BTreeException
Gets the values attribute of the BFile object

Returns:
The values value
Throws:
java.io.IOException - Description of the Exception
org.dbxml.core.filer.BTreeException - Description of the Exception

open

public boolean open()
             throws org.dbxml.core.DBException
Description of the Method

Returns:
Description of the Return Value
Throws:
org.dbxml.core.DBException - Description of the Exception

put

public long put(org.dbxml.core.data.Value key,
                byte[] data,
                boolean overwrite)
         throws ReadOnlyException
Throws:
ReadOnlyException

put

public long put(org.dbxml.core.data.Value key,
                ByteArray value)
         throws ReadOnlyException
Description of the Method

Parameters:
key - Description of the Parameter
value - Description of the Parameter
Returns:
Description of the Return Value
Throws:
ReadOnlyException

put

public long put(org.dbxml.core.data.Value key,
                ByteArray value,
                boolean overwrite)
         throws ReadOnlyException
Description of the Method

Parameters:
key - Description of the Parameter
value - Description of the Parameter
overwrite - Description of the Parameter
Returns:
Description of the Return Value
Throws:
ReadOnlyException

remove

public void remove(org.dbxml.core.data.Value key)
            throws ReadOnlyException
Description of the Method

Parameters:
key - Description of the Parameter
Throws:
ReadOnlyException

remove

public void remove(long p)
            throws ReadOnlyException
Throws:
ReadOnlyException

remove

protected void remove(org.exist.storage.store.BFile.DataPage page,
                      long p)
               throws org.dbxml.core.filer.BTreeException,
                      java.io.IOException,
                      ReadOnlyException
Description of the Method

Parameters:
page - Description of the Parameter
p - Description of the Parameter
Throws:
org.dbxml.core.filer.BTreeException - Description of the Exception
java.io.IOException - Description of the Exception
ReadOnlyException

setCompression

public void setCompression(boolean compress)
Sets the compression attribute of the BFile object

Parameters:
compress - The new compression value

setLocation

public void setLocation(java.lang.String location)
Sets the location attribute of the BFile object

Parameters:
location - The new location value

update

public long update(org.dbxml.core.data.Value key,
                   ByteArray value)
            throws ReadOnlyException
Update a key/value pair.

Parameters:
key - Description of the Parameter
value - Description of the Parameter
Returns:
Description of the Return Value
Throws:
ReadOnlyException

update

public long update(long p,
                   org.dbxml.core.data.Value key,
                   ByteArray value)
            throws ReadOnlyException
Update the key/value pair found at the logical address p.

Parameters:
p - Description of the Parameter
key - Description of the Parameter
value - Description of the Parameter
Returns:
Description of the Return Value
Throws:
ReadOnlyException

update

protected long update(long p,
                      org.exist.storage.store.BFile.DataPage page,
                      org.dbxml.core.data.Value key,
                      ByteArray value)
               throws org.dbxml.core.filer.BTreeException,
                      java.io.IOException,
                      ReadOnlyException
Update the key/value pair with logical address p and stored in page.

Parameters:
p - Description of the Parameter
page - Description of the Parameter
key - Description of the Parameter
value - Description of the Parameter
Throws:
org.dbxml.core.filer.BTreeException - Description of the Exception
java.io.IOException - Description of the Exception
ReadOnlyException


Copyright (C) Wolfgang Meier. All rights reserved.