int noToMoveInPass = Math.min(noToMove, m_bufferSize);
m_dbFile.seek(curReadPos);
int noRead = m_dbFile.read(barr, 0, noToMoveInPass);
if (noRead != noToMoveInPass)
{
throw new NotEnoughDataException(noToMoveInPass, noRead);
}
m_dbFile.seek(curWritePos);
m_dbFile.write(barr, 0, noToMoveInPass);
curReadPos += noToMoveInPass;
curWritePos += noToMoveInPass;
noToMove -= noToMoveInPass;
}
// Only bother to do this if we have record move listeners.
if (hasRecordMoveListeners())
{
byte[] keySizeArr = new byte[KEY_SIZE_SIZE];
long pos = writePos + 1 + RECORD_SIZE_SIZE;
m_dbFile.seek(pos);
int noRead = m_dbFile.read(keySizeArr);
if (noRead != KEY_SIZE_SIZE)
{
throw new NotEnoughDataException(KEY_SIZE_SIZE, noRead, pos);
}
int keySize = IntegerSerializer.getInteger(keySizeArr);
byte[] karr = new byte[keySize];
noRead = m_dbFile.read(karr);
if (noRead != keySize)
{
throw new NotEnoughDataException(KEY_SIZE_SIZE, noRead, pos + KEY_SIZE_SIZE);
}
K key = m_keySerializer.interpret(karr);
notifyRecordMoveListeners(key, readPos, writePos);
}
}