use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.
the class WriteTransactionCommandOrderingTest method injectAllPossibleCommands.
private TransactionRecordState injectAllPossibleCommands() {
RecordChangeSet recordChangeSet = mock(RecordChangeSet.class);
RecordChanges<Integer, LabelTokenRecord, Void> labelTokenChanges = mock(RecordChanges.class);
RecordChanges<Integer, RelationshipTypeTokenRecord, Void> relationshipTypeTokenChanges = mock(RecordChanges.class);
RecordChanges<Integer, PropertyKeyTokenRecord, Void> propertyKeyTokenChanges = mock(RecordChanges.class);
RecordChanges<Long, NodeRecord, Void> nodeRecordChanges = mock(RecordChanges.class);
RecordChanges<Long, RelationshipRecord, Void> relationshipRecordChanges = mock(RecordChanges.class);
RecordChanges<Long, PropertyRecord, PrimitiveRecord> propertyRecordChanges = mock(RecordChanges.class);
RecordChanges<Long, RelationshipGroupRecord, Integer> relationshipGroupChanges = mock(RecordChanges.class);
RecordChanges<Long, SchemaRecord, SchemaRule> schemaRuleChanges = mock(RecordChanges.class);
when(recordChangeSet.getLabelTokenChanges()).thenReturn(labelTokenChanges);
when(recordChangeSet.getRelationshipTypeTokenChanges()).thenReturn(relationshipTypeTokenChanges);
when(recordChangeSet.getPropertyKeyTokenChanges()).thenReturn(propertyKeyTokenChanges);
when(recordChangeSet.getNodeRecords()).thenReturn(nodeRecordChanges);
when(recordChangeSet.getRelRecords()).thenReturn(relationshipRecordChanges);
when(recordChangeSet.getPropertyRecords()).thenReturn(propertyRecordChanges);
when(recordChangeSet.getRelGroupRecords()).thenReturn(relationshipGroupChanges);
when(recordChangeSet.getSchemaRuleChanges()).thenReturn(schemaRuleChanges);
List<RecordProxy<Long, NodeRecord, Void>> nodeChanges = new LinkedList<>();
RecordChange<Long, NodeRecord, Void> deletedNode = mock(RecordChange.class);
when(deletedNode.getBefore()).thenReturn(inUseNode());
when(deletedNode.forReadingLinkage()).thenReturn(missingNode());
nodeChanges.add(deletedNode);
RecordChange<Long, NodeRecord, Void> createdNode = mock(RecordChange.class);
when(createdNode.getBefore()).thenReturn(missingNode());
when(createdNode.forReadingLinkage()).thenReturn(createdNode());
nodeChanges.add(createdNode);
RecordChange<Long, NodeRecord, Void> updatedNode = mock(RecordChange.class);
when(updatedNode.getBefore()).thenReturn(inUseNode());
when(updatedNode.forReadingLinkage()).thenReturn(inUseNode());
nodeChanges.add(updatedNode);
when(nodeRecordChanges.changes()).thenReturn(nodeChanges);
when(nodeRecordChanges.changeSize()).thenReturn(3);
when(recordChangeSet.changeSize()).thenReturn(3);
when(labelTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, LabelTokenRecord, Void>>emptyList());
when(relationshipTypeTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, RelationshipTypeTokenRecord, Void>>emptyList());
when(propertyKeyTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, PropertyKeyTokenRecord, Void>>emptyList());
when(relationshipRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipRecord, Void>>emptyList());
when(propertyRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, PropertyRecord, PrimitiveRecord>>emptyList());
when(relationshipGroupChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipGroupRecord, Integer>>emptyList());
when(schemaRuleChanges.changes()).thenReturn(Collections.<RecordProxy<Long, SchemaRecord, SchemaRule>>emptyList());
NeoStores neoStores = mock(NeoStores.class);
when(neoStores.getNodeStore()).thenReturn(mock(NodeStore.class));
when(neoStores.getRelationshipGroupStore()).thenReturn(mock(RelationshipGroupStore.class));
when(neoStores.getRelationshipStore()).thenReturn(mock(RelationshipStore.class));
return new TransactionRecordState(neoStores, mock(IntegrityValidator.class), recordChangeSet, 0, null, null, null, null, null);
}
use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_1 method visitLabelTokenCommand.
private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
// id+in_use(byte)+type_blockId(int)+nr_type_records(int)
int id = channel.getInt();
byte inUseFlag = channel.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
LabelTokenRecord record = new LabelTokenRecord(id);
record.setInUse(inUse);
record.setNameId(channel.getInt());
int nrTypeRecords = channel.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(channel);
if (dr == null) {
return null;
}
record.addNameRecord(dr);
}
return new Command.LabelTokenCommand(null, record);
}
use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_0 method visitLabelTokenCommand.
private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
// id+in_use(byte)+type_blockId(int)+nr_type_records(int)
int id = channel.getInt();
byte inUseFlag = channel.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
LabelTokenRecord record = new LabelTokenRecord(id);
record.setInUse(inUse);
record.setNameId(channel.getInt());
int nrTypeRecords = channel.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(channel);
if (dr == null) {
return null;
}
record.addNameRecord(dr);
}
return new Command.LabelTokenCommand(null, record);
}
use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportLabelInconsistencies.
@Test
public void shouldReportLabelInconsistencies() throws Exception {
// given
StoreAccess access = fixture.directStoreAccess().nativeStores();
LabelTokenRecord record = access.getLabelTokenStore().getRecord(1, access.getLabelTokenStore().newRecord(), FORCE);
record.setNameId(20);
record.setInUse(true);
access.getLabelTokenStore().updateRecord(record);
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.LABEL, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.
the class CacheSmallStoresRecordAccessTest method shouldServePropertyKeysAndRelationshipLabelsFromSuppliedArrayCaches.
@Test
public void shouldServePropertyKeysAndRelationshipLabelsFromSuppliedArrayCaches() throws Exception {
// given
RecordAccess delegate = mock(RecordAccess.class);
PropertyKeyTokenRecord propertyKey0 = new PropertyKeyTokenRecord(0);
PropertyKeyTokenRecord propertyKey2 = new PropertyKeyTokenRecord(2);
PropertyKeyTokenRecord propertyKey1 = new PropertyKeyTokenRecord(1);
RelationshipTypeTokenRecord relationshipType0 = new RelationshipTypeTokenRecord(0);
RelationshipTypeTokenRecord relationshipType1 = new RelationshipTypeTokenRecord(1);
RelationshipTypeTokenRecord relationshipType2 = new RelationshipTypeTokenRecord(2);
LabelTokenRecord label0 = new LabelTokenRecord(0);
LabelTokenRecord label1 = new LabelTokenRecord(1);
LabelTokenRecord label2 = new LabelTokenRecord(2);
CacheSmallStoresRecordAccess recordAccess = new CacheSmallStoresRecordAccess(delegate, new PropertyKeyTokenRecord[] { propertyKey0, propertyKey1, propertyKey2 }, new RelationshipTypeTokenRecord[] { relationshipType0, relationshipType1, relationshipType2 }, new LabelTokenRecord[] { label0, label1, label2 });
// when
assertThat(recordAccess.propertyKey(0), isDirectReferenceTo(propertyKey0));
assertThat(recordAccess.propertyKey(1), isDirectReferenceTo(propertyKey1));
assertThat(recordAccess.propertyKey(2), isDirectReferenceTo(propertyKey2));
assertThat(recordAccess.relationshipType(0), isDirectReferenceTo(relationshipType0));
assertThat(recordAccess.relationshipType(1), isDirectReferenceTo(relationshipType1));
assertThat(recordAccess.relationshipType(2), isDirectReferenceTo(relationshipType2));
assertThat(recordAccess.label(0), isDirectReferenceTo(label0));
assertThat(recordAccess.label(1), isDirectReferenceTo(label1));
assertThat(recordAccess.label(2), isDirectReferenceTo(label2));
// then
verifyZeroInteractions(delegate);
}
Aggregations