protected LogRecord computeNext() {
while (true) {
String docid = null;
for (PeekingIterator<LogRecord> it : cursors) {
if (it.hasNext()) {
LogRecord peek = it.peek();
if (docid == null || peek.get_docid().compareTo(docid) < 0) {
docid = peek.get_docid();
}
}
}
if (docid != null) {
LogRecord merged = null;
for (PeekingIterator<LogRecord> it : cursors) {
if (it.hasNext()) {
LogRecord peek = it.peek();
if (peek.get_docid().equals(docid)) {
it.next();
if (merged == null) {
merged = peek;
} else if (peek.is_deleted()) {
if (peek.is_set_fields() || peek.is_set_variables() || peek.is_set_categories()) {
merged = peek;
merged.set_deleted(false);
} else {
merged = null;
}