Search in sources :

Example 46 with PropertyRecord

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

the class PropertyRecordFormatTest method writeAndReadRecordWithRelativeReferences.

@Test
public void writeAndReadRecordWithRelativeReferences() throws IOException {
    int recordSize = recordFormat.getRecordSize(new IntStoreHeader(DATA_SIZE));
    long recordId = 0xF1F1F1F1F1F1L;
    int recordOffset = pageCursor.getOffset();
    PropertyRecord record = createRecord(recordFormat, recordId);
    recordFormat.write(record, pageCursor, recordSize);
    PropertyRecord recordFromStore = recordFormat.newRecord();
    recordFromStore.setId(recordId);
    resetCursor(pageCursor, recordOffset);
    recordFormat.read(recordFromStore, pageCursor, RecordLoad.NORMAL, recordSize);
    // records should be the same
    assertEquals(record.getNextProp(), recordFromStore.getNextProp());
    assertEquals(record.getPrevProp(), recordFromStore.getPrevProp());
    // now lets try to read same data into a record with different id - we should get different absolute references
    resetCursor(pageCursor, recordOffset);
    PropertyRecord recordWithOtherId = recordFormat.newRecord();
    recordWithOtherId.setId(1L);
    recordFormat.read(recordWithOtherId, pageCursor, RecordLoad.NORMAL, recordSize);
    verifyDifferentReferences(record, recordWithOtherId);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) IntStoreHeader(org.neo4j.kernel.impl.store.IntStoreHeader) Test(org.junit.Test)

Example 47 with PropertyRecord

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

the class PhysicalLogCommandReaderV2_1Test method shouldReadPropertyCommandWithDeletedDynamicRecords.

@Test
public void shouldReadPropertyCommandWithDeletedDynamicRecords() throws Exception {
    // GIVEN
    PhysicalLogCommandReaderV2_1 reader = new PhysicalLogCommandReaderV2_1();
    InMemoryClosableChannel data = new InMemoryClosableChannel();
    long id = 5;
    int keyId = 6;
    byte[] data1 = new byte[] { 1, 2, 3, 4, 5 };
    byte[] data2 = new byte[] { 6, 7, 8, 9, 10 };
    long value = 1234;
    PropertyRecord property = new PropertyRecord(id);
    property.setInUse(true);
    property.addPropertyBlock(propertyBlockWithSomeDynamicRecords(keyId, STRING, value, data1, data2));
    property.addDeletedRecord(dynamicRecord(false, null, STRING.intValue()));
    property.addDeletedRecord(dynamicRecord(false, null, STRING.intValue()));
    // WHEN
    new PropertyCommand(new PropertyRecord(id), property).serialize(data);
    // THEN
    PropertyCommand readCommand = (PropertyCommand) reader.read(data);
    PropertyRecord readRecord = readCommand.getAfter();
    assertEquals(id, readRecord.getId());
    PropertyBlock readBlock = Iterables.single((Iterable<PropertyBlock>) readRecord);
    assertArrayEquals(data1, readBlock.getValueRecords().get(0).getData());
    assertArrayEquals(data2, readBlock.getValueRecords().get(1).getData());
    assertEquals(2, readRecord.getDeletedRecords().size());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyCommand) Test(org.junit.Test)

Example 48 with PropertyRecord

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

the class PhysicalLogCommandReaderV3_0Test method readPropertyCommandWithSecondaryUnit.

@Test
public void readPropertyCommandWithSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyRecord before = new PropertyRecord(1);
    PropertyRecord after = new PropertyRecord(2);
    after.setRequiresSecondaryUnit(true);
    after.setSecondaryUnitId(78);
    new Command.PropertyCommand(before, after).serialize(channel);
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.read(channel);
    assertTrue(command instanceof Command.PropertyCommand);
    Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command;
    // Then
    assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
    assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
    verifySecondaryUnit(after, neoStoreCommand.getAfter());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 49 with PropertyRecord

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

the class NeoStoreTransactionApplierTest method shouldApplyNodePropertyCommandToTheStore.

// PROPERTY COMMAND
@Test
public void shouldApplyNodePropertyCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final PropertyRecord before = new PropertyRecord(11);
    final PropertyRecord after = new PropertyRecord(12);
    after.setNodeId(42);
    final Command command = new Command.PropertyCommand(before, after);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(lockService, times(1)).acquireNodeLock(42, LockService.LockType.WRITE_LOCK);
    verify(propertyStore, times(1)).updateRecord(after);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) 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 50 with PropertyRecord

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

the class NeoStoreTransactionApplierTest method shouldApplyNodePropertyCommandToTheStoreInRecovery.

@Test
public void shouldApplyNodePropertyCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    final PropertyRecord before = new PropertyRecord(11);
    final PropertyRecord after = new PropertyRecord(12);
    after.setNodeId(42);
    final Command command = new Command.PropertyCommand(before, after);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(lockService, times(1)).acquireNodeLock(42, LockService.LockType.WRITE_LOCK);
    verify(propertyStore, times(1)).setHighestPossibleIdInUse(after.getId());
    verify(propertyStore, times(1)).updateRecord(after);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) 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)

Aggregations

PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)230 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)86 Test (org.junit.Test)75 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)37 Test (org.junit.jupiter.api.Test)36 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)35 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)28 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)19 ArrayList (java.util.ArrayList)17 Value (org.neo4j.values.storable.Value)17 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)14 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)14 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)9 IOException (java.io.IOException)8 InterruptedIOException (java.io.InterruptedIOException)8 Pair (org.neo4j.helpers.collection.Pair)8 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)8 NodeStore (org.neo4j.kernel.impl.store.NodeStore)8