use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class LegacyIndexTransactionStateImplTest method removalOfRelationshipIndexDoesNotClearNodeCommandsForNodeIndexWithSameName.
@Test
public void removalOfRelationshipIndexDoesNotClearNodeCommandsForNodeIndexWithSameName() {
LegacyIndexTransactionStateImpl state = newLegacyIndexTxState();
state.addNode("index", 1, "key", "value");
state.addRelationship("index", 1, "key", "value", 11, 11);
state.deleteIndex(IndexEntityType.Relationship, "index");
IndexDefineCommand indexDefinedCommand = new IndexDefineCommand();
indexDefinedCommand.getOrAssignIndexNameId("index");
indexDefinedCommand.getOrAssignKeyId("key");
IndexCommand.DeleteCommand delete = new IndexCommand.DeleteCommand();
delete.init(1, IndexEntityType.Relationship.id());
Set<Command> expectedCommands = new HashSet<>(Arrays.asList(indexDefinedCommand, delete, addNode(1, 1, 1, "value")));
assertEquals(expectedCommands, extractCommands(state));
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class BatchingTransactionAppenderConcurrencyTest method tx.
protected TransactionToApply tx() {
NodeRecord before = new NodeRecord(0);
NodeRecord after = new NodeRecord(0);
after.setInUse(true);
Command.NodeCommand nodeCommand = new Command.NodeCommand(before, after);
PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(asList((Command) nodeCommand));
tx.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
return new TransactionToApply(tx);
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class LogEntryParserDispatcherV6Test method shouldParserCommandsUsingAGivenFactory.
@Test
public void shouldParserCommandsUsingAGivenFactory() throws IOException {
// given
// The record, it will be used as before and after
NodeRecord theRecord = new NodeRecord(1);
Command.NodeCommand nodeCommand = new Command.NodeCommand(theRecord, theRecord);
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
channel.put(NeoCommandType.NODE_COMMAND);
channel.putLong(theRecord.getId());
// record image before
// not in use
channel.put((byte) 0);
// number of dynamic records in use
channel.putInt(0);
// record image after
// not in use
channel.put((byte) 0);
// number of dynamic records in use
channel.putInt(0);
channel.getCurrentPosition(marker);
// when
final LogEntryParser parser = version.entryParser(LogEntryByteCodes.COMMAND);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(command, logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class LogEntryParserV2_2Test method shouldParseCommandsUsingAGivenFactory.
@Test
public void shouldParseCommandsUsingAGivenFactory() throws IOException {
// given
Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(0), new NodeRecord(0));
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
nodeCommand.serialize(channel);
channel.getCurrentPosition(marker);
// when
final LogEntryParser parser = version.entryParser(LogEntryByteCodes.COMMAND);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(command, logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldParseAnOldCommandLogEntry.
@Test
public void shouldParseAnOldCommandLogEntry() throws IOException {
// given
LogEntryVersion version = LogEntryVersion.V2_1;
Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(10), new NodeRecord(10));
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
channel.put(version.byteCode());
channel.put(LogEntryByteCodes.COMMAND);
// ignored data
// identifier ignored
channel.putInt(42);
// actual used data
nodeCommand.serialize(channel);
// when
final LogEntry logEntry = logEntryReader.readLogEntry(channel);
// then
assertTrue(logEntry instanceof IdentifiableLogEntry);
assertEquals(command, ((IdentifiableLogEntry) logEntry).getEntry());
}
Aggregations