use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class SchemaRecordCheckTest method dynamicRecord.
private DynamicRecord dynamicRecord(long id) {
DynamicRecord record = new DynamicRecord(id);
record.setType(RecordAccessStub.SCHEMA_RECORD_TYPE);
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportUnreferencedUniquenessConstraint.
@Test
public void shouldReportUnreferencedUniquenessConstraint() throws Exception {
// given
int ruleId = 0;
DynamicRecord record = inUse(dynamicRecord(ruleId));
ConstraintRule rule = uniquenessConstraintRule(ruleId, labelId, propertyKeyId, ruleId);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule);
add(inUse(new LabelTokenRecord(labelId)));
add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
// when
check(record);
SchemaRecordCheck obligationChecker = checker().forObligationChecking();
ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record);
// then
verify(report).missingObligation(SchemaRule.Kind.CONSTRAINT_INDEX_RULE);
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportConstraintIndexNotReferencingBack.
@Test
public void shouldReportConstraintIndexNotReferencingBack() throws Exception {
// given
int ruleId1 = 0;
int ruleId2 = 1;
DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) ruleId1);
ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId1);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);
add(inUse(new LabelTokenRecord(labelId)));
add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
// when
check(record1);
check(record2);
SchemaRecordCheck obligationChecker = checker().forObligationChecking();
ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record1);
check(obligationChecker, record2);
// then
verify(report).constraintIndexRuleNotReferencingBack(record2);
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class TransactionWriter method withName.
private static <T extends TokenRecord> T withName(T record, int[] dynamicIds, String name) {
if (dynamicIds == null || dynamicIds.length == 0) {
throw new IllegalArgumentException("No dynamic records for storing the name.");
}
record.setInUse(true);
byte[] data = PropertyStore.encodeString(name);
if (data.length > dynamicIds.length * NAME_STORE_BLOCK_SIZE) {
throw new IllegalArgumentException(String.format("[%s] is too long to fit in %d blocks", name, dynamicIds.length));
} else if (data.length <= (dynamicIds.length - 1) * NAME_STORE_BLOCK_SIZE) {
throw new IllegalArgumentException(String.format("[%s] is to short to fill %d blocks", name, dynamicIds.length));
}
for (int i = 0; i < dynamicIds.length; i++) {
byte[] part = new byte[Math.min(NAME_STORE_BLOCK_SIZE, data.length - i * NAME_STORE_BLOCK_SIZE)];
System.arraycopy(data, i * NAME_STORE_BLOCK_SIZE, part, 0, part.length);
DynamicRecord dynamicRecord = new DynamicRecord(dynamicIds[i]);
dynamicRecord.setInUse(true);
dynamicRecord.setData(part);
dynamicRecord.setCreated();
record.addNameRecord(dynamicRecord);
}
record.setNameId(dynamicIds[0]);
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class NodeRecordCheckTest method shouldDynamicLabelRecordsNotInUse.
@Test
public void shouldDynamicLabelRecordsNotInUse() throws Exception {
// given
long[] labelIds = createLabels(100);
NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
add(node);
DynamicRecord labelsRecord1 = notInUse(array(new DynamicRecord(1)));
DynamicRecord labelsRecord2 = notInUse(array(new DynamicRecord(2)));
Collection<DynamicRecord> labelRecords = asList(labelsRecord1, labelsRecord2);
DynamicArrayStore.allocateFromNumbers(new ArrayList<>(), labelIds, new NotUsedReusableRecordsAllocator(52, labelRecords));
assertDynamicRecordChain(labelsRecord1, labelsRecord2);
node.setLabelField(DynamicNodeLabels.dynamicPointer(labelRecords), labelRecords);
addNodeDynamicLabels(labelsRecord1);
addNodeDynamicLabels(labelsRecord2);
// when
ConsistencyReport.NodeConsistencyReport report = check(node);
// then
verify(report).dynamicLabelRecordNotInUse(labelsRecord1);
verify(report).dynamicLabelRecordNotInUse(labelsRecord2);
}
Aggregations