public class IndexData extends Object
Modifier and Type | Class and Description |
---|---|
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
|
static class |
IndexData.PendingChange
Utility class which maintains information about a pending index update.
|
Modifier and Type | Field and Description |
---|---|
static byte |
ASCENDING_COLUMN_FLAG |
static Comparator<byte[]> |
BYTE_CODE_COMPARATOR |
protected static byte[] |
EMPTY_PREFIX |
static IndexData.Entry |
FIRST_ENTRY
special entry which is less than any other entry
|
static byte |
IGNORE_NULLS_INDEX_FLAG |
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 int |
MAX_COLUMNS
Max number of columns in an index
|
static 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 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
|
static byte |
SPECIAL_INDEX_FLAG |
static byte |
UNIQUE_INDEX_FLAG |
static byte |
UNKNOWN_INDEX_FLAG |
Modifier | Constructor and Description |
---|---|
protected |
IndexData(TableImpl table,
int number,
int uniqueEntryCount,
int uniqueEntryCountOffset) |
Modifier and Type | Method and Description |
---|---|
static void |
commitAll(IndexData.PendingChange change) |
Object[] |
constructIndexRow(Map<String,?> row)
Constructs an array of values appropriate for this index from the given
column values.
|
Object[] |
constructIndexRow(String colName,
Object value)
Constructs an array of values appropriate for this index from the given
column value.
|
Object[] |
constructIndexRowFromEntry(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(TableImpl table,
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(Object[] startRow,
boolean startInclusive,
Object[] endRow,
boolean endInclusive)
Gets a new cursor for this index, narrowed to the range defined by the
given startRow and endRow.
|
void |
deleteRow(Object[] row,
RowIdImpl rowId)
Removes a row from this index
|
protected IndexData.DataPage |
findDataPage(IndexData.Entry entry)
Finds the data page for the given entry.
|
List<IndexData.ColumnDescriptor> |
getColumns()
Returns the Columns for this index (unmodifiable)
|
protected IndexData.DataPage |
getDataPage(int pageNumber)
Gets the data page for the pageNumber.
|
int |
getEntryCount()
Returns the number of index entries in the index.
|
JetFormat |
getFormat() |
int |
getIndexDataNumber() |
List<Index> |
getIndexes() |
byte |
getIndexFlags() |
protected int |
getMaxPageEntrySize() |
String |
getName() |
int |
getOwnedPageCount()
Returns the number of database pages owned by this index data.
|
PageChannel |
getPageChannel() |
Index |
getPrimaryIndex() |
protected int |
getRootPageNumber() |
TableImpl |
getTable() |
int |
getUniqueEntryCount() |
int |
getUniqueEntryCountOffset() |
void |
initialize()
Forces initialization of this index (actual parsing of index pages).
|
protected boolean |
isBackingPrimaryKey() |
boolean |
isInitialized()
Whether or not the complete index state has been read.
|
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.
|
IndexData.PendingChange |
prepareAddRow(Object[] row,
RowIdImpl rowId,
IndexData.PendingChange nextChange)
Prepares to add a row to this index.
|
IndexData.PendingChange |
prepareUpdateRow(Object[] oldRow,
RowIdImpl rowId,
Object[] newRow,
IndexData.PendingChange nextChange)
Prepares to update a row in this index.
|
void |
read(ByteBuffer tableBuffer,
List<ColumnImpl> 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).
|
static void |
rollbackAll(IndexData.PendingChange change) |
boolean |
shouldIgnoreNulls()
Whether or not
null values are actually recorded in the index. |
String |
toString() |
void |
update()
Writes the current index state to the database.
|
void |
validate()
Used by unit tests to validate the internal status of the index.
|
protected static void |
writeDataPage(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.impl.TableCreator creator,
ByteBuffer buffer)
Writes the index definitions into a table definition buffer.
|
protected static void |
writeRowCountDefinitions(com.healthmarketscience.jackcess.impl.TableCreator creator,
ByteBuffer buffer)
Writes the index row count definitions into a table definition buffer.
|
protected static final org.apache.commons.logging.Log LOG
public static final IndexData.Entry FIRST_ENTRY
public static final IndexData.Entry LAST_ENTRY
public static final Object MAX_VALUE
public static final Object MIN_VALUE
protected static final int INVALID_INDEX_PAGE_NUMBER
public static final int MAX_COLUMNS
protected static final byte[] EMPTY_PREFIX
public static final byte ASCENDING_COLUMN_FLAG
public static final byte UNIQUE_INDEX_FLAG
public static final byte IGNORE_NULLS_INDEX_FLAG
public static final byte SPECIAL_INDEX_FLAG
public static final byte UNKNOWN_INDEX_FLAG
public static final Comparator<byte[]> BYTE_CODE_COMPARATOR
protected IndexData(TableImpl table, int number, int uniqueEntryCount, int uniqueEntryCountOffset)
public static IndexData create(TableImpl table, ByteBuffer tableBuffer, int number, JetFormat format) throws IOException
IOException
public String getName()
public TableImpl getTable()
public JetFormat getFormat()
public PageChannel getPageChannel()
public Index getPrimaryIndex()
public List<Index> getIndexes()
public byte getIndexFlags()
public int getIndexDataNumber()
public int getUniqueEntryCount()
public int getUniqueEntryCountOffset()
protected boolean isBackingPrimaryKey()
public boolean shouldIgnoreNulls()
null
values are actually recorded in the index.public boolean isUnique()
Some notes about uniqueness:
null
entries
invalid for a unique indexpublic List<IndexData.ColumnDescriptor> getColumns()
public boolean isInitialized()
protected int getRootPageNumber()
protected int getMaxPageEntrySize()
public int getOwnedPageCount()
public void validate() throws IOException
IOException
public int getEntryCount() throws IOException
Forces index initialization.
IOException
public void initialize() throws IOException
IOException
public void update() throws IOException
Forces index initialization.
IOException
public void read(ByteBuffer tableBuffer, List<ColumnImpl> availableColumns) throws IOException
tableBuffer
- table definition buffer to read from initial infoavailableColumns
- Columns that this index may useIOException
protected static void writeRowCountDefinitions(com.healthmarketscience.jackcess.impl.TableCreator creator, ByteBuffer buffer)
creator
- description of the indexes to writebuffer
- Buffer to write toprotected static void writeDefinitions(com.healthmarketscience.jackcess.impl.TableCreator creator, ByteBuffer buffer) throws IOException
creator
- description of the indexes to writebuffer
- Buffer to write toIOException
public IndexData.PendingChange prepareAddRow(Object[] row, RowIdImpl rowId, IndexData.PendingChange nextChange) throws IOException
Forces index initialization.
row
- Row to addrowId
- rowId of the row to be addedIOException
public IndexData.PendingChange prepareUpdateRow(Object[] oldRow, RowIdImpl rowId, Object[] newRow, IndexData.PendingChange nextChange) throws IOException
Forces index initialization.
oldRow
- Row to be removednewRow
- Row to be addedrowId
- rowId of the row to be updatedIOException
public void deleteRow(Object[] row, RowIdImpl rowId) throws IOException
Forces index initialization.
row
- Row to removerowId
- rowId of the row to be removedIOException
public static void commitAll(IndexData.PendingChange change) throws IOException
IOException
public static void rollbackAll(IndexData.PendingChange change) throws IOException
IOException
public IndexData.EntryCursor cursor() throws IOException
Forces index initialization.
IOException
public IndexData.EntryCursor cursor(Object[] startRow, boolean startInclusive, Object[] endRow, boolean endInclusive) throws IOException
Forces index initialization.
startRow
- the first row of data for the cursor, or null
for
the first entrystartInclusive
- whether or not startRow is inclusive or exclusiveendRow
- the last row of data for the cursor, or null
for
the last entryendInclusive
- whether or not endRow is inclusive or exclusiveIOException
protected static int missingIndexToInsertionPoint(int idx)
public Object[] constructIndexRowFromEntry(Object... values)
IllegalArgumentException
- if the wrong number of values are
providedpublic Object[] constructIndexRow(String colName, Object value)
null
if not all
columns for this index were providedpublic Object[] constructIndexRow(Map<String,?> row)
null
if not all
columns for this index were providedprotected void writeDataPage(IndexData.DataPage dataPage) throws IOException
IOException
protected static void writeDataPage(ByteBuffer buffer, IndexData.DataPage dataPage, int tdefPageNumber, JetFormat format) throws IOException
IOException
protected void readDataPage(IndexData.DataPage dataPage) throws IOException
IOException
protected IndexData.DataPage findDataPage(IndexData.Entry entry) throws IOException
IOException
protected IndexData.DataPage getDataPage(int pageNumber) throws IOException
IOException
Copyright © 2005–2018. All rights reserved.