public final int OFFSET_COLUMN_FIXED_DATA_OFFSET;
public final int OFFSET_TABLE_DEF_LOCATION;
- public final int OFFSET_NUM_ROWS_ON_PAGE;
- public final int OFFSET_ROW_LOCATION_BLOCK;
public final int OFFSET_ROW_START;
public final int OFFSET_USAGE_MAP_START;
public final int OFFSET_FREE_SPACE;
public final int OFFSET_NUM_ROWS_ON_DATA_PAGE;
+ public final int MAX_NUM_ROWS_ON_DATA_PAGE;
public final int OFFSET_INDEX_COMPRESSED_BYTE_COUNT;
public final int OFFSET_INDEX_ENTRY_MASK;
OFFSET_COLUMN_FIXED_DATA_OFFSET = defineOffsetColumnFixedDataOffset();
OFFSET_TABLE_DEF_LOCATION = defineOffsetTableDefLocation();
- OFFSET_NUM_ROWS_ON_PAGE = defineOffsetNumRowsOnPage();
- OFFSET_ROW_LOCATION_BLOCK = defineOffsetRowLocationBlock();
OFFSET_ROW_START = defineOffsetRowStart();
OFFSET_USAGE_MAP_START = defineOffsetUsageMapStart();
OFFSET_FREE_SPACE = defineOffsetFreeSpace();
OFFSET_NUM_ROWS_ON_DATA_PAGE = defineOffsetNumRowsOnDataPage();
+ MAX_NUM_ROWS_ON_DATA_PAGE = defineMaxNumRowsOnDataPage();
OFFSET_INDEX_COMPRESSED_BYTE_COUNT = defineOffsetIndexCompressedByteCount();
OFFSET_INDEX_ENTRY_MASK = defineOffsetIndexEntryMask();
protected abstract int defineOffsetColumnFixedDataOffset();
protected abstract int defineOffsetTableDefLocation();
- protected abstract int defineOffsetNumRowsOnPage();
- protected abstract int defineOffsetRowLocationBlock();
protected abstract int defineOffsetRowStart();
protected abstract int defineOffsetUsageMapStart();
protected abstract int defineOffsetFreeSpace();
protected abstract int defineOffsetNumRowsOnDataPage();
+ protected abstract int defineMaxNumRowsOnDataPage();
protected abstract int defineOffsetIndexCompressedByteCount();
protected abstract int defineOffsetIndexEntryMask();
@Override
protected int defineOffsetTableDefLocation() { return 4; }
- @Override
- protected int defineOffsetNumRowsOnPage() { return 12; }
- @Override
- protected int defineOffsetRowLocationBlock() { return 16; }
@Override
protected int defineOffsetRowStart() { return 14; }
protected int defineOffsetFreeSpace() { return 2; }
@Override
protected int defineOffsetNumRowsOnDataPage() { return 12; }
+ @Override
+ protected int defineMaxNumRowsOnDataPage() { return 256; }
@Override
protected int defineOffsetIndexCompressedByteCount() { return 24; }
int rowSize = rowData[i].remaining();
int rowSpaceUsage = getRowSpaceUsage(rowSize, getFormat());
short freeSpaceInPage = dataPage.getShort(getFormat().OFFSET_FREE_SPACE);
- if (freeSpaceInPage < rowSpaceUsage) {
+ int rowsOnPage = getRowsOnDataPage(dataPage, getFormat());
+ if((freeSpaceInPage < rowSpaceUsage) ||
+ (rowsOnPage >= getFormat().MAX_NUM_ROWS_ON_DATA_PAGE)) {
// Last data page is full. Create a new one.
writeDataPage(dataPage, pageNumber);
getFormat())); //Free space in this page
dataPage.putInt(_tableDefPageNumber); //Page pointer to table definition
dataPage.putInt(0); //Unknown
- dataPage.putInt(0); //Number of records on this page
+ dataPage.putShort((short)0); //Number of rows on this page
int pageNumber = _addRowBufferH.getPageNumber();
getPageChannel().writePage(dataPage, pageNumber);
_ownedPages.addPageNumber(pageNumber);