// While we have records in the journal.
while ((pos = journal.getNextRecordLocation(pos)) != null) {
Packet packet = journal.read(pos);
byte[] buffer = packet.sliceAsBytes();
if (buffer[0] == DELETE_BYTE) {
UUID id = new UUID(buffer, 1);
results.remove(id);
unusedMarks.add(pos);
RecordLocation loc = (RecordLocation)marks.remove(id);
if (loc != null) {
pendingMarks.remove(loc);
unusedMarks.add(loc);
}
markLock.notify();
}
else {
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer));
ois.readByte();
String queue = ois.readUTF();
byte[] buf = new byte[UUID_LENGTH];
ois.read(buf);
UUID id = new UUID(buf);
results.put(id, new HolderImpl(queue, id));
marks.put(id, pos);
pendingMarks.add(pos);
}
}