Search in sources :

Example 66 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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);
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command)

Example 67 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class BatchingTransactionAppenderTest method singleCreateNodeCommand.

private Collection<StorageCommand> singleCreateNodeCommand(long id) {
    Collection<StorageCommand> commands = new ArrayList<>();
    NodeRecord before = new NodeRecord(id);
    NodeRecord after = new NodeRecord(id);
    after.setInUse(true);
    commands.add(new NodeCommand(before, after));
    return commands;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)

Example 68 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldInvalidateTheCacheWhenTheNodeBecomesDense.

@Test
public void shouldInvalidateTheCacheWhenTheNodeBecomesDense() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final NodeRecord before = new NodeRecord(11);
    before.setLabelField(42, Arrays.asList(one));
    before.setInUse(true);
    before.setDense(false);
    final NodeRecord after = new NodeRecord(12);
    after.setInUse(true);
    after.setDense(true);
    after.setLabelField(42, Arrays.asList(one, two, three));
    final Command.NodeCommand command = new Command.NodeCommand(before, after);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(lockService, times(1)).acquireNodeLock(command.getKey(), LockService.LockType.WRITE_LOCK);
    verify(nodeStore, times(1)).updateRecord(after);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 69 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 70 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Aggregations

NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)391 Test (org.junit.Test)154 Test (org.junit.jupiter.api.Test)108 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)73 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)63 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)58 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)46 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)42 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)40 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)40 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)38 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)32 ArrayList (java.util.ArrayList)30 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)30 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)30 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)30 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 NodeStore (org.neo4j.kernel.impl.store.NodeStore)28 Command (org.neo4j.kernel.impl.transaction.command.Command)27 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)17