use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class LogCommandSerializationV4_0Test method shouldReadRelationshipGroupCommand.
@Test
void shouldReadRelationshipGroupCommand() throws Throwable {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipGroupRecord before = new RelationshipGroupRecord(42).initialize(false, 3, NULL_REF, NULL_REF, NULL_REF, NULL_REF, NULL_REF);
RelationshipGroupRecord after = new RelationshipGroupRecord(42).initialize(true, 3, 4, 5, 6, 7, 8);
after.setCreated();
new Command.RelationshipGroupCommand(writer(), before, after).serialize(channel);
// When
CommandReader reader = createReader();
StorageCommand command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipGroupCommand);
Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
// Then
assertBeforeAndAfterEquals(relationshipGroupCommand, before, after);
}
use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class LogCommandSerializationV4_0Test method readRelationshipGroupCommandWithFixedReferenceFormat.
@Test
void readRelationshipGroupCommandWithFixedReferenceFormat() throws IOException {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipGroupRecord before = new RelationshipGroupRecord(42).initialize(false, 3, NULL_REF, NULL_REF, NULL_REF, NULL_REF, NULL_REF);
before.setUseFixedReferences(true);
RelationshipGroupRecord after = new RelationshipGroupRecord(42).initialize(true, 3, 4, 5, 6, 7, 8);
after.setUseFixedReferences(true);
after.setCreated();
new Command.RelationshipGroupCommand(writer(), before, after).serialize(channel);
// When
CommandReader reader = createReader();
StorageCommand command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipGroupCommand);
Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
// Then
assertBeforeAndAfterEquals(relationshipGroupCommand, before, after);
assertTrue(relationshipGroupCommand.getBefore().isUseFixedReferences());
assertTrue(relationshipGroupCommand.getAfter().isUseFixedReferences());
}
use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class LogCommandSerializationV4_0Test method shouldReadInternalPropertyKeyCommand.
@Test
void shouldReadInternalPropertyKeyCommand() throws Exception {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
PropertyKeyTokenRecord after = before.copy();
after.initialize(true, 13);
after.setCreated();
after.setInternal(true);
new Command.PropertyKeyTokenCommand(writer(), before, after).serialize(channel);
// When
CommandReader reader = createReader();
StorageCommand command = reader.read(channel);
assertTrue(command instanceof Command.PropertyKeyTokenCommand);
Command.PropertyKeyTokenCommand propertyKeyTokenCommand = (Command.PropertyKeyTokenCommand) command;
// Then
assertBeforeAndAfterEquals(propertyKeyTokenCommand, before, after);
}
use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class LogCommandSerializationV4_0Test method shouldReadRelationshipCommand.
@Test
void shouldReadRelationshipCommand() throws Throwable {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipRecord before = new RelationshipRecord(42);
before.setLinks(-1, -1, -1);
RelationshipRecord after = new RelationshipRecord(42);
after.initialize(true, 0, 1, 2, 3, 4, 5, 6, 7, true, true);
after.setCreated();
new Command.RelationshipCommand(writer(), before, after).serialize(channel);
// When
CommandReader reader = createReader();
StorageCommand command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipCommand);
Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
// Then
assertBeforeAndAfterEquals(relationshipCommand, before, after);
}
use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class LogTruncationTest method assertHandlesLogTruncation.
private void assertHandlesLogTruncation(Command cmd) throws IOException {
inMemoryChannel.reset();
cmd.serialize(inMemoryChannel);
int bytesSuccessfullyWritten = inMemoryChannel.writerPosition();
try {
StorageCommand command = serialization.read(inMemoryChannel);
assertEquals(cmd, command);
} catch (Exception e) {
throw new AssertionError("Failed to deserialize " + cmd + ", because: ", e);
}
bytesSuccessfullyWritten--;
while (bytesSuccessfullyWritten-- > 0) {
inMemoryChannel.reset();
cmd.serialize(inMemoryChannel);
inMemoryChannel.truncateTo(bytesSuccessfullyWritten);
Command command = null;
try {
command = serialization.read(inMemoryChannel);
} catch (ReadPastEndException e) {
assertNull(command, "Deserialization did not detect log truncation!" + "Record: " + cmd + ", deserialized: " + command);
}
}
}
Aggregations