use of org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry in project neo4j by neo4j.
the class LogEntrySortingCursor method perhapsFetchEntriesFromChannel.
private void perhapsFetchEntriesFromChannel() throws IOException {
if (idToFetchFrom > 0) {
// we still have entry to return from the map...
return;
}
LogEntry entry;
while ((entry = reader.readLogEntry(channel)) != null) {
if (!(entry instanceof IdentifiableLogEntry)) {
throw new IllegalStateException("reading from a log which is not a legacy one???");
}
final IdentifiableLogEntry identifiableLogEntry = (IdentifiableLogEntry) entry;
final int identifier = identifiableLogEntry.getIdentifier();
final LogEntry inner = identifiableLogEntry.getEntry();
List<LogEntry> list = provideList(idToEntries, identifier);
list.add(inner);
if (inner instanceof LogEntryCommit) {
idToFetchFrom = identifier;
break;
}
}
}
use of org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry in project neo4j by neo4j.
the class LegacyLogEntryReaderTest method shouldReadTheEntries.
@Test
public void shouldReadTheEntries() throws IOException {
// given
final LogEntry start = new LogEntryStart(0, 1, 2, 3, EMPTY_ADDITIONAL_ARRAY, UNSPECIFIED);
NodeRecord record = new NodeRecord(42);
final LogEntry command = new LogEntryCommand(new Command.NodeCommand(record, record));
final LogEntry commit = new OnePhaseCommit(42, 43);
final LogEntryReader<ReadableLogChannel> logEntryReader = mock(LogEntryReader.class);
when(logEntryReader.readLogEntry(any(ReadableLogChannel.class))).thenReturn(new IdentifiableLogEntry(start, 1), new IdentifiableLogEntry(command, 1), new IdentifiableLogEntry(commit, 1), null);
final LegacyLogEntryReader reader = new LegacyLogEntryReader(fs, from -> logEntryReader);
// when
final IOCursor<LogEntry> cursor = reader.openReadableChannel(input).other();
// then
assertTrue(cursor.next());
assertEquals(start, cursor.get());
assertTrue(cursor.next());
assertEquals(command, cursor.get());
assertTrue(cursor.next());
assertEquals(commit, cursor.get());
assertFalse(cursor.next());
cursor.close();
}
Aggregations