page = nextPage; p = db.getCurrentPage(nextPage); offset = 0;
final DOMFilePageHeader ph = p.getPageHeader();  if (offset >= ph.getDataLength()) {  final long nextPage = ph.getNextDataPage(); if (nextPage < 0) { LOG.debug("bad link to next " + p.page.getPageInfo()); lock.release(lockKey); return null; } page = nextPage; p = db.getCurrentPage(nextPage); offset = 0; }  lastTID = ByteConversion.byteToShort(p.data, offset); final short l = ByteConversion.byteToShort(p.data, offset + 2); final Value nextVal = new Value(p.data, offset + 4, l); nextVal.setAddress(createPointer((int) page, lastTID)); offset = offset + 4 + l; lock.release(lockKey); return nextVal; } catch (BTreeException e) { LOG.warn(e); } catch (IOException e) { LOG.warn(e);
		public Object next() {			Lock lock = db.getLock();			try {				try {					lock.acquire(lockKey);					lock.enter(lockKey);				} catch (LockException e) {					return null;				}				if (node != null) {					db.setOwnerObject(lockKey);					long addr = db.findValue(lockKey, node);					if(addr == KEY_NOT_FOUND)						return null;					RecordPos rec = findValuePosition(addr);					page = rec.page.getPageNum();					p = rec.page;					offset = rec.offset - 2;					node = null;				} else if (-1 < startAddress) {					RecordPos rec = findValuePosition(startAddress);					page = rec.page.getPageNum();					offset = rec.offset - 2;					p = rec.page;					startAddress = -1;				} else if (page > -1)					p = db.getCurrentPage(page);				else {					lock.release(lockKey);					return null;				}				DOMFilePageHeader ph = p.getPageHeader();				if (offset >= ph.getDataLength()) {					long nextPage = ph.getNextDataPage();					if (nextPage < 0) {						LOG.debug(							"bad link to next " + p.page.getPageInfo());						lock.release(lockKey);						return null;					}					page = nextPage;					p = db.getCurrentPage(nextPage);					offset = 0;				}				db.buffer.add(p);				short tid = ByteConversion.byteToShort(p.data, offset);				short l = ByteConversion.byteToShort(p.data, offset + 2);				int dataStart = offset + 4;				Value nextVal = new Value(p.data, dataStart, l);				nextVal.setAddress(createPointer((int) page, tid));				lastTID = tid;				offset = dataStart + l;				lock.release(lockKey);				return nextVal;			} catch (BTreeException e) {				LOG.warn(e);			} catch (IOException e) {				LOG.warn(e);			}			lock.release(lockKey);			return null;		}