if (freeSpaceInPage < (rowSize + _format.SIZE_ROW_LOCATION)) {
if (freeSpaceInPage < rowSpaceUsage) {
  public void addRows(List<? extends Object[]> rows) throws IOException {    ByteBuffer dataPage = _pageChannel.createPageBuffer();    ByteBuffer[] rowData = new ByteBuffer[rows.size()];    Iterator<? extends Object[]> iter = rows.iterator();    for (int i = 0; iter.hasNext(); i++) {      rowData[i] = createRow((Object[]) iter.next(), _format.MAX_ROW_SIZE);    }    List<Integer> pageNumbers = _ownedPages.getPageNumbers();    int pageNumber;    int rowSize;    if (pageNumbers.size() == 0) {      //No data pages exist.  Create a new one.      pageNumber = newDataPage(dataPage, rowData[0]);    } else {      //Get the last data page.      //Not bothering to check other pages for free space.      pageNumber = ((Integer) pageNumbers.get(pageNumbers.size() - 1)).intValue();      _pageChannel.readPage(dataPage, pageNumber);    }    for (int i = 0; i < rowData.length; i++) {      rowSize = rowData[i].limit();      short freeSpaceInPage = dataPage.getShort(_format.OFFSET_FREE_SPACE);      if (freeSpaceInPage < (rowSize + _format.SIZE_ROW_LOCATION)) {        //Last data page is full.  Create a new one.        if (rowSize > _format.MAX_ROW_SIZE) {          throw new IOException("Row size " + rowSize + " is too large");        }        _pageChannel.writePage(dataPage, pageNumber);        dataPage.clear();        pageNumber = newDataPage(dataPage, rowData[i]);        _freeSpacePages.removePageNumber(pageNumber);        freeSpaceInPage = dataPage.getShort(_format.OFFSET_FREE_SPACE);      }      //Decrease free space record.      dataPage.putShort(_format.OFFSET_FREE_SPACE, (short) (freeSpaceInPage -          rowSize - _format.SIZE_ROW_LOCATION));      //Increment row count record.      short rowCount = dataPage.getShort(_format.OFFSET_NUM_ROWS_ON_DATA_PAGE);      dataPage.putShort(_format.OFFSET_NUM_ROWS_ON_DATA_PAGE, (short) (rowCount + 1));      short rowLocation = findRowEnd(dataPage, rowCount, _format);      rowLocation -= rowSize;      dataPage.putShort(getRowStartOffset(rowCount, _format), rowLocation);      dataPage.position(rowLocation);      dataPage.put(rowData[i]);      Iterator<Index> indIter = _indexes.iterator();      while (indIter.hasNext()) {        Index index = (Index) indIter.next();        index.addRow((Object[]) rows.get(i), pageNumber, (byte) rowCount);      }    }    _pageChannel.writePage(dataPage, pageNumber);        //Update tdef page    ByteBuffer tdefPage = _pageChannel.createPageBuffer();    _pageChannel.readPage(tdefPage, _tableDefPageNumber);    tdefPage.putInt(_format.OFFSET_NUM_ROWS, ++_rowCount);    Iterator<Index> indIter = _indexes.iterator();    for (int i = 0; i < _indexes.size(); i++) {      tdefPage.putInt(_format.OFFSET_INDEX_DEF_BLOCK +          i * _format.SIZE_INDEX_DEFINITION + 4, _rowCount);      Index index = (Index) indIter.next();      index.update();    }    _pageChannel.writePage(tdefPage, _tableDefPageNumber);  }