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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations