varColumnOffsets[varColumnOffsetsIndex++] = offset;
  ByteBuffer createRow(Object[] rowArray, int maxRowSize) throws IOException {    ByteBuffer buffer = _pageChannel.createPageBuffer();    buffer.putShort((short) _columns.size());    NullMask nullMask = new NullMask(_columns.size());    Iterator iter;    int index = 0;    Column col;    List<Object> row = new ArrayList<Object>(Arrays.asList(rowArray));        //Append null for arrays that are too small    for (int i = rowArray.length; i < _columnCount; i++) {      row.add(null);    }        for (iter = _columns.iterator(); iter.hasNext() && index < row.size(); index++) {      col = (Column) iter.next();      if (!col.isVariableLength()) {        //Fixed length column data comes first (remainingRowLength is ignored        //when writing fixed length data        buffer.put(col.write(row.get(index), 0));      }      if (col.getType() == DataType.BOOLEAN) {        if (row.get(index) != null) {          if (!((Boolean) row.get(index)).booleanValue()) {            //Booleans are stored in the null mask            nullMask.markNull(index);          }        }      } else if (row.get(index) == null) {        nullMask.markNull(index);      }    }    int varLengthCount = Column.countVariableLength(_columns);    // figure out how much space remains for var length data.  first, account    // for already written space    maxRowSize -= buffer.position();    // now, account for trailer space    maxRowSize -= (nullMask.byteSize() + 4 + (varLengthCount * 2));        short[] varColumnOffsets = new short[varLengthCount];    index = 0;    int varColumnOffsetsIndex = 0;    //Now write out variable length column data    for (iter = _columns.iterator(); iter.hasNext() && index < row.size();         index++) {      col = (Column) iter.next();      short offset = (short) buffer.position();      if (col.isVariableLength()) {        if (row.get(index) != null) {          ByteBuffer varDataBuf = col.write(row.get(index), maxRowSize);          maxRowSize -= varDataBuf.remaining();          buffer.put(varDataBuf);        }        varColumnOffsets[varColumnOffsetsIndex++] = offset;      }    }    buffer.putShort((short) buffer.position()); //EOD marker    //Now write out variable length offsets    //Offsets are stored in reverse order    for (int i = varColumnOffsets.length - 1; i >= 0; i--) {      buffer.putShort(varColumnOffsets[i]);    }    buffer.putShort((short) varLengthCount);  //Number of var length columns    buffer.put(nullMask.wrap());  //Null mask    buffer.limit(buffer.position());    buffer.flip();    if (LOG.isDebugEnabled()) {      LOG.debug("Creating new data block:\n" + ByteUtil.toHexString(buffer, buffer.limit()));    }    return buffer;  }