final int valueLen = value.length;  DOMPage page = getCurrentPage();  if (page == null || page.len + 4 + valueLen > page.data.length) { DOMPage newPage = new DOMPage(); if (page != null) { DOMFilePageHeader ph = page.getPageHeader(); ph.setNextDataPage(newPage.getPageNum()); newPage.getPageHeader().setPrevDataPage(page.getPageNum()); page.setDirty(true); buffer.add(page); } page = newPage; setCurrentPage(newPage); }  final DOMFilePageHeader ph = page.getPageHeader(); final short tid = ph.getNextTID(); ByteConversion.shortToByte(tid, page.data, page.len); page.len += 2;  ByteConversion.shortToByte((short) valueLen, page.data, page.len); page.len += 2;  System.arraycopy(value, 0, page.data, page.len, valueLen); page.len += valueLen; ph.incRecordCount(); ph.setDataLength(page.len); page.setDirty(true); buffer.add(page, 2);  final long p = StorageAddress.createPointer((int) page.getPageNum(), tid); return p;
if (value.length > fileHeader.getWorkSize()) { LOG.debug("creating overflow page"); OverflowDOMPage overflow = new OverflowDOMPage(); overflow.write(value); byte[] pnum = ByteConversion.longToByte(overflow.getPageNum()); return add(pnum, true); } else return add(value, false);
	public long add(byte[] value) throws ReadOnlyException {		if (value == null)			return -1;		final int valueLen = value.length;		// always append data to the end of the file		DOMPage page = getCurrentPage();		// does value fit into current data page?		if (page == null || page.len + 4 + valueLen > page.data.length) {			DOMPage newPage = new DOMPage();			if (page != null) {				DOMFilePageHeader ph = page.getPageHeader();				ph.setNextDataPage(newPage.getPageNum());				newPage.getPageHeader().setPrevDataPage(page.getPageNum());				page.setDirty(true);				buffer.add(page);			}			page = newPage;			setCurrentPage(newPage);		}		// save tuple identifier		final DOMFilePageHeader ph = page.getPageHeader();		final short tid = ph.getNextTID();		ByteConversion.shortToByte(tid, page.data, page.len);		page.len += 2;		// save data length		ByteConversion.shortToByte((short) valueLen, page.data, page.len);		page.len += 2;		// save data		System.arraycopy(value, 0, page.data, page.len, valueLen);		page.len += valueLen;		ph.incRecordCount();		ph.setDataLength(page.len);		page.setDirty(true);		buffer.add(page, 2);		// create pointer from pageNum and offset into page		final long p = StorageAddress.createPointer((int) page.getPageNum(), tid);		return p;	}