Elexis: Das führende OpenSource-Arztpraxisprogamm
im deutschsprachigen Raum
Java doc für Elexis version 2.1.7.dev vom 01.09.2013

com.healthmarketscience.jackcess
Class IndexData

java.lang.Object
  extended by com.healthmarketscience.jackcess.IndexData
Direct Known Subclasses:
BigIndexData, SimpleIndexData

public abstract class IndexData
extends java.lang.Object

Access table index data. This is the actual data which backs a logical Index, where one or more logical indexes can be backed by the same index data.


Nested Class Summary
static class IndexData.ColumnDescriptor
          Information about the columns in an index.
protected static class IndexData.DataPage
          Object used to maintain state about an Index page.
static class IndexData.Entry
          A single leaf entry in an index (points to a single row)
 class IndexData.EntryCursor
          Utility class to traverse the entries in the Index.
static class IndexData.EntryType
          type attributes for Entries which simplify comparisons
 
Field Summary
protected static byte[] EMPTY_PREFIX
           
static IndexData.Entry FIRST_ENTRY
          special entry which is less than any other entry
protected static int INVALID_INDEX_PAGE_NUMBER
           
static IndexData.Entry LAST_ENTRY
          special entry which is greater than any other entry
protected static org.apache.commons.logging.Log LOG
           
static java.lang.Object MAX_VALUE
          special object which will always be greater than any other value, when searching for an index entry range in a multi-value index
static java.lang.Object MIN_VALUE
          special object which will always be greater than any other value, when searching for an index entry range in a multi-value index
 
Constructor Summary
protected IndexData(Table table, int number, int uniqueEntryCount, int uniqueEntryCountOffset)
           
 
Method Summary
 void addRow(java.lang.Object[] row, RowId rowId)
          Adds a row to this index Forces index initialization.
 java.lang.Object[] constructIndexRow(java.util.Map<java.lang.String,?> row)
          Constructs an array of values appropriate for this index from the given column values.
 java.lang.Object[] constructIndexRow(java.lang.String colName, java.lang.Object value)
          Constructs an array of values appropriate for this index from the given column value.
 java.lang.Object[] constructIndexRowFromEntry(java.lang.Object... values)
          Constructs an array of values appropriate for this index from the given column values, expected to match the columns for this index.
static IndexData create(Table table, java.nio.ByteBuffer tableBuffer, int number, JetFormat format)
          Creates an IndexData appropriate for the given table, using information from the given table definition buffer.
 IndexData.EntryCursor cursor()
          Gets a new cursor for this index.
 IndexData.EntryCursor cursor(java.lang.Object[] startRow, boolean startInclusive, java.lang.Object[] endRow, boolean endInclusive)
          Gets a new cursor for this index, narrowed to the range defined by the given startRow and endRow.
 void deleteRow(java.lang.Object[] row, RowId rowId)
          Removes a row from this index Forces index initialization.
protected abstract  IndexData.DataPage findDataPage(IndexData.Entry entry)
          Finds the data page for the given entry.
 java.util.List<IndexData.ColumnDescriptor> getColumns()
          Returns the Columns for this index (unmodifiable)
protected abstract  IndexData.DataPage getDataPage(int pageNumber)
          Gets the data page for the pageNumber.
protected  int getEntryCount()
          Returns the number of index entries in the index.
 JetFormat getFormat()
           
 int getIndexDataNumber()
           
 java.util.List<Index> getIndexes()
           
 byte getIndexFlags()
           
protected  int getMaxPageEntrySize()
           
 int getOwnedPageCount()
          Returns the number of database pages owned by this index data.
 PageChannel getPageChannel()
           
 Index getPrimaryIndex()
           
protected  int getRootPageNumber()
           
 Table getTable()
           
 int getUniqueEntryCount()
           
 int getUniqueEntryCountOffset()
           
 void initialize()
          Forces initialization of this index (actual parsing of index pages). normally, the index will not be initialized until the entries are actually needed.
protected  boolean isBackingPrimaryKey()
           
 boolean isInitialized()
          Whether or not the complete index state has been read.
protected  boolean isReadOnly()
           
 boolean isUnique()
          Whether or not index entries must be unique.
protected static int missingIndexToInsertionPoint(int idx)
          Returns the valid insertion point for an index indicating a missing entry.
 void read(java.nio.ByteBuffer tableBuffer, java.util.List<Column> availableColumns)
          Read the rest of the index info from a tableBuffer
protected  void readDataPage(IndexData.DataPage dataPage)
          Reads an index page, populating the correct collection based on the page type (node or leaf).
protected abstract  void readIndexEntries()
          Reads the actual index entries.
protected  void setReadOnly()
           
 boolean shouldIgnoreNulls()
          Whether or not null values are actually recorded in the index.
 java.lang.String toString()
           
 void update()
          Writes the current index state to the database.
protected abstract  void updateImpl()
          Writes the current index state to the database.
protected static void writeDataPage(java.nio.ByteBuffer buffer, IndexData.DataPage dataPage, int tdefPageNumber, JetFormat format)
          Writes the data page info to the given buffer.
protected  void writeDataPage(IndexData.DataPage dataPage)
          Write the given index page out to a buffer
protected static void writeDefinitions(com.healthmarketscience.jackcess.TableCreator creator, java.nio.ByteBuffer buffer)
          Writes the index definitions into a table definition buffer.
protected static void writeRowCountDefinitions(com.healthmarketscience.jackcess.TableCreator creator, java.nio.ByteBuffer buffer)
          Writes the index row count definitions into a table definition buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG

FIRST_ENTRY

public static final IndexData.Entry FIRST_ENTRY
special entry which is less than any other entry


LAST_ENTRY

public static final IndexData.Entry LAST_ENTRY
special entry which is greater than any other entry


MAX_VALUE

public static final java.lang.Object MAX_VALUE
special object which will always be greater than any other value, when searching for an index entry range in a multi-value index


MIN_VALUE

public static final java.lang.Object MIN_VALUE
special object which will always be greater than any other value, when searching for an index entry range in a multi-value index


INVALID_INDEX_PAGE_NUMBER

protected static final int INVALID_INDEX_PAGE_NUMBER
See Also:
Constant Field Values

EMPTY_PREFIX

protected static final byte[] EMPTY_PREFIX
Constructor Detail

IndexData

protected IndexData(Table table,
                    int number,
                    int uniqueEntryCount,
                    int uniqueEntryCountOffset)
Method Detail

create

public static IndexData create(Table table,
                               java.nio.ByteBuffer tableBuffer,
                               int number,
                               JetFormat format)
                        throws java.io.IOException
Creates an IndexData appropriate for the given table, using information from the given table definition buffer.

Throws:
java.io.IOException

getTable

public Table getTable()

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

getPrimaryIndex

public Index getPrimaryIndex()
Returns:
the "main" logical index which is backed by this data.

getIndexes

public java.util.List<Index> getIndexes()
Returns:
All of the Indexes backed by this data (unmodifiable List)

getIndexFlags

public byte getIndexFlags()

getIndexDataNumber

public int getIndexDataNumber()

getUniqueEntryCount

public int getUniqueEntryCount()

getUniqueEntryCountOffset

public int getUniqueEntryCountOffset()

isBackingPrimaryKey

protected boolean isBackingPrimaryKey()

shouldIgnoreNulls

public boolean shouldIgnoreNulls()
Whether or not null values are actually recorded in the index.


isUnique

public boolean isUnique()
Whether or not index entries must be unique.

Some notes about uniqueness:


getColumns

public java.util.List<IndexData.ColumnDescriptor> getColumns()
Returns the Columns for this index (unmodifiable)


isInitialized

public boolean isInitialized()
Whether or not the complete index state has been read.


getRootPageNumber

protected int getRootPageNumber()

setReadOnly

protected void setReadOnly()

isReadOnly

protected boolean isReadOnly()

getMaxPageEntrySize

protected int getMaxPageEntrySize()

getOwnedPageCount

public int getOwnedPageCount()
Returns the number of database pages owned by this index data.


getEntryCount

protected int getEntryCount()
                     throws java.io.IOException
Returns the number of index entries in the index. Only called by unit tests.

Forces index initialization.

Throws:
java.io.IOException

initialize

public void initialize()
                throws java.io.IOException
Forces initialization of this index (actual parsing of index pages). normally, the index will not be initialized until the entries are actually needed.

Throws:
java.io.IOException

update

public void update()
            throws java.io.IOException
Writes the current index state to the database.

Forces index initialization.

Throws:
java.io.IOException

read

public void read(java.nio.ByteBuffer tableBuffer,
                 java.util.List<Column> availableColumns)
          throws java.io.IOException
Read the rest of the index info from a tableBuffer

Parameters:
tableBuffer - table definition buffer to read from initial info
availableColumns - Columns that this index may use
Throws:
java.io.IOException

writeRowCountDefinitions

protected static void writeRowCountDefinitions(com.healthmarketscience.jackcess.TableCreator creator,
                                               java.nio.ByteBuffer buffer)
Writes the index row count definitions into a table definition buffer.

Parameters:
buffer - Buffer to write to
indexes - List of IndexBuilders to write definitions for

writeDefinitions

protected static void writeDefinitions(com.healthmarketscience.jackcess.TableCreator creator,
                                       java.nio.ByteBuffer buffer)
                                throws java.io.IOException
Writes the index definitions into a table definition buffer.

Parameters:
buffer - Buffer to write to
indexes - List of IndexBuilders to write definitions for
Throws:
java.io.IOException

addRow

public void addRow(java.lang.Object[] row,
                   RowId rowId)
            throws java.io.IOException
Adds a row to this index

Forces index initialization.

Parameters:
row - Row to add
rowId - rowId of the row to be added
Throws:
java.io.IOException

deleteRow

public void deleteRow(java.lang.Object[] row,
                      RowId rowId)
               throws java.io.IOException
Removes a row from this index

Forces index initialization.

Parameters:
row - Row to remove
rowId - rowId of the row to be removed
Throws:
java.io.IOException

cursor

public IndexData.EntryCursor cursor()
                             throws java.io.IOException
Gets a new cursor for this index.

Forces index initialization.

Throws:
java.io.IOException

cursor

public IndexData.EntryCursor cursor(java.lang.Object[] startRow,
                                    boolean startInclusive,
                                    java.lang.Object[] endRow,
                                    boolean endInclusive)
                             throws java.io.IOException
Gets a new cursor for this index, narrowed to the range defined by the given startRow and endRow.

Forces index initialization.

Parameters:
startRow - the first row of data for the cursor, or null for the first entry
startInclusive - whether or not startRow is inclusive or exclusive
endRow - the last row of data for the cursor, or null for the last entry
endInclusive - whether or not endRow is inclusive or exclusive
Throws:
java.io.IOException

missingIndexToInsertionPoint

protected static int missingIndexToInsertionPoint(int idx)
Returns the valid insertion point for an index indicating a missing entry.


constructIndexRowFromEntry

public java.lang.Object[] constructIndexRowFromEntry(java.lang.Object... values)
Constructs an array of values appropriate for this index from the given column values, expected to match the columns for this index.

Returns:
the appropriate sparse array of data
Throws:
java.lang.IllegalArgumentException - if the wrong number of values are provided

constructIndexRow

public java.lang.Object[] constructIndexRow(java.lang.String colName,
                                            java.lang.Object value)
Constructs an array of values appropriate for this index from the given column value.

Returns:
the appropriate sparse array of data or null if not all columns for this index were provided

constructIndexRow

public java.lang.Object[] constructIndexRow(java.util.Map<java.lang.String,?> row)
Constructs an array of values appropriate for this index from the given column values.

Returns:
the appropriate sparse array of data or null if not all columns for this index were provided

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeDataPage

protected void writeDataPage(IndexData.DataPage dataPage)
                      throws java.io.IOException
Write the given index page out to a buffer

Throws:
java.io.IOException

writeDataPage

protected static void writeDataPage(java.nio.ByteBuffer buffer,
                                    IndexData.DataPage dataPage,
                                    int tdefPageNumber,
                                    JetFormat format)
                             throws java.io.IOException
Writes the data page info to the given buffer.

Throws:
java.io.IOException

readDataPage

protected void readDataPage(IndexData.DataPage dataPage)
                     throws java.io.IOException
Reads an index page, populating the correct collection based on the page type (node or leaf).

Throws:
java.io.IOException

updateImpl

protected abstract void updateImpl()
                            throws java.io.IOException
Writes the current index state to the database. Index has already been initialized.

Throws:
java.io.IOException

readIndexEntries

protected abstract void readIndexEntries()
                                  throws java.io.IOException
Reads the actual index entries.

Throws:
java.io.IOException

findDataPage

protected abstract IndexData.DataPage findDataPage(IndexData.Entry entry)
                                            throws java.io.IOException
Finds the data page for the given entry.

Throws:
java.io.IOException

getDataPage

protected abstract IndexData.DataPage getDataPage(int pageNumber)
                                           throws java.io.IOException
Gets the data page for the pageNumber.

Throws:
java.io.IOException

Elexis: Das führende OpenSource-Arztpraxisprogamm
im deutschsprachigen Raum
Java doc für Elexis version 2.1.7.dev vom 01.09.2013