use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportRelationshipGroupInconsistenciesFromDifferentLogs.
@Test
public void shouldReportRelationshipGroupInconsistenciesFromDifferentLogs() throws IOException {
// Given
File log1 = logFile(1);
File log2 = logFile(2);
File log3 = logFile(3);
writeTxContent(log1, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, -1, -1, -1, -1, -1, -1, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(21, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(21, -1, -1, -1, -1, -1, -1, false)));
writeTxContent(log2, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 9, 5, 6, true), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)));
writeTxContent(log3, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(53, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(53, 1, 2, 30, 4, 14, 6, true)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, false)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP_GROUP);
// Then
assertEquals(2, handler.recordInconsistencies.size());
RelationshipGroupRecord seenRecord1 = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).committed.record();
RelationshipGroupRecord currentRecord1 = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord1.getId());
assertEquals(4, seenRecord1.getFirstLoop());
assertEquals(42, currentRecord1.getId());
assertEquals(9, currentRecord1.getFirstLoop());
RelationshipGroupRecord seenRecord2 = (RelationshipGroupRecord) handler.recordInconsistencies.get(1).committed.record();
RelationshipGroupRecord currentRecord2 = (RelationshipGroupRecord) handler.recordInconsistencies.get(1).current.record();
assertEquals(42, seenRecord2.getId());
assertTrue(seenRecord2.inUse());
assertEquals(42, currentRecord2.getId());
assertFalse(currentRecord2.inUse());
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportRelationshipGroupInconsistenciesFromSingleLog.
@Test
public void shouldReportRelationshipGroupInconsistenciesFromSingleLog() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, -1, -1, -1, -1, -1, -1, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(21, 1, 2, 3, 4, 5, 7, true), new RelationshipGroupRecord(21, -1, -1, -1, -1, -1, -1, false)));
writeTxContent(log, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(53, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(53, 1, 2, 30, 4, 14, 6, true)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 9, 5, 6, true), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP_GROUP);
// Then
assertEquals(1, handler.recordInconsistencies.size());
RelationshipGroupRecord seenRecord = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).committed.record();
RelationshipGroupRecord currentRecord = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord.getId());
assertEquals(4, seenRecord.getFirstLoop());
assertEquals(42, currentRecord.getId());
assertEquals(9, currentRecord.getFirstLoop());
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class RelationshipGroupCheckTypeTest method inUseRecordEquality.
@Test
public void inUseRecordEquality() {
RelationshipGroupRecord record1 = new RelationshipGroupRecord(1);
record1.initialize(true, 1, 2, 3, 4, 5, 6);
record1.setSecondaryUnitId(42);
RelationshipGroupRecord record2 = record1.clone();
RelationshipGroupCheckType check = new RelationshipGroupCheckType();
assertTrue(check.equal(record1, record2));
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_1 method visitRelationshipGroupCommand.
private Command visitRelationshipGroupCommand(ReadableChannel channel) throws IOException {
long id = channel.getLong();
byte inUseByte = channel.get();
boolean inUse = inUseByte == Record.IN_USE.byteValue();
if (inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseByte);
}
int type = shortToUnsignedInt(channel.getShort());
RelationshipGroupRecord record = new RelationshipGroupRecord(id, type);
record.setInUse(inUse);
record.setNext(channel.getLong());
record.setFirstOut(channel.getLong());
record.setFirstIn(channel.getLong());
record.setFirstLoop(channel.getLong());
record.setOwningNode(channel.getLong());
return new Command.RelationshipGroupCommand(null, record);
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class Loaders method relationshipGroupLoader.
public static Loader<Long, RelationshipGroupRecord, Integer> relationshipGroupLoader(final RecordStore<RelationshipGroupRecord> store) {
return new Loader<Long, RelationshipGroupRecord, Integer>() {
@Override
public RelationshipGroupRecord newUnused(Long key, Integer type) {
RelationshipGroupRecord record = new RelationshipGroupRecord(key);
record.setType(type);
return andMarkAsCreated(record);
}
@Override
public RelationshipGroupRecord load(Long key, Integer type) {
return store.getRecord(key, store.newRecord(), NORMAL);
}
@Override
public void ensureHeavy(RelationshipGroupRecord record) {
// Not needed
}
@Override
public RelationshipGroupRecord clone(RelationshipGroupRecord record) {
return record.clone();
}
};
}
Aggregations