Quellcode durchsuchen

move index pagetypes to the public type; some minor cleanup

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@314 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/rel_1_1_14
James Ahlborn vor 16 Jahren
Ursprung
Commit
d52cf53037

+ 19
- 14
src/java/com/healthmarketscience/jackcess/Index.java Datei anzeigen

@@ -71,9 +71,6 @@ public abstract class Index implements Comparable<Index> {

private static final short COLUMN_UNUSED = -1;

private static final byte INDEX_NODE_PAGE_TYPE = (byte)0x03;
private static final byte INDEX_LEAF_PAGE_TYPE = (byte)0x04;

private static final byte ASCENDING_COLUMN_FLAG = (byte)0x01;

private static final byte UNIQUE_INDEX_FLAG = (byte)0x01;
@@ -176,13 +173,7 @@ public abstract class Index implements Comparable<Index> {
_table = table;
_uniqueEntryCount = uniqueEntryCount;
_uniqueEntryCountOffset = uniqueEntryCountOffset;
// the max data we can fit on a page is the min of the space on the page
// vs the number of bytes which can be encoded in the entry mask
_maxPageEntrySize = Math.min(
(getFormat().PAGE_SIZE -
(getFormat().OFFSET_INDEX_ENTRY_MASK +
getFormat().SIZE_INDEX_ENTRY_MASK)),
(getFormat().SIZE_INDEX_ENTRY_MASK * 8));
_maxPageEntrySize = calcMaxPageEntrySize(_table.getFormat());
}

public Table getTable() {
@@ -746,8 +737,8 @@ public abstract class Index implements Comparable<Index> {
ByteBuffer buffer = _indexBufferH.getPageBuffer(getPageChannel());
buffer.put(dataPage.isLeaf() ?
INDEX_LEAF_PAGE_TYPE :
INDEX_NODE_PAGE_TYPE ); //Page type
PageTypes.INDEX_LEAF :
PageTypes.INDEX_NODE ); //Page type
buffer.put((byte) 0x01); //Unknown
buffer.putShort((short) 0); //Free space
buffer.putInt(getTable().getTableDefPageNumber());
@@ -909,9 +900,9 @@ public abstract class Index implements Comparable<Index> {
throws IOException
{
byte pageType = buffer.get(0);
if(pageType == INDEX_LEAF_PAGE_TYPE) {
if(pageType == PageTypes.INDEX_LEAF) {
return true;
} else if(pageType == INDEX_NODE_PAGE_TYPE) {
} else if(pageType == PageTypes.INDEX_NODE) {
return false;
}
throw new IOException("Unexpected page type " + pageType);
@@ -1222,6 +1213,20 @@ public abstract class Index implements Comparable<Index> {
throw new IllegalArgumentException("Values was null for valid entry");
}

/**
* Returns the maximum amount of entry data which can be encoded on any
* index page.
*/
private static int calcMaxPageEntrySize(JetFormat format)
{
// the max data we can fit on a page is the min of the space on the page
// vs the number of bytes which can be encoded in the entry mask
int pageDataSize = (format.PAGE_SIZE -
(format.OFFSET_INDEX_ENTRY_MASK +
format.SIZE_INDEX_ENTRY_MASK));
int entryMaskSize = (format.SIZE_INDEX_ENTRY_MASK * 8);
return Math.min(pageDataSize, entryMaskSize);
}
/**
* Information about the columns in an index. Also encodes new index

+ 9
- 3
src/java/com/healthmarketscience/jackcess/PageTypes.java Datei anzeigen

@@ -33,11 +33,17 @@ package com.healthmarketscience.jackcess;
*/
public interface PageTypes {
/** invalid page type */
public static final byte INVALID = (byte)0x00;
/** Data page */
public static final byte DATA = 0x1;
public static final byte DATA = (byte)0x01;
/** Table definition page */
public static final byte TABLE_DEF = 0x2;
public static final byte TABLE_DEF = (byte)0x02;
/** intermediate index page pointing to other index pages */
public static final byte INDEX_NODE = (byte)0x03;
/** leaf index page containing actual entries */
public static final byte INDEX_LEAF = (byte)0x04;
/** Table usage map page */
public static final byte USAGE_MAP = 0x5;
public static final byte USAGE_MAP = (byte)0x05;
}

Laden…
Abbrechen
Speichern