use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexEntryConflictExceptionTest method shouldMakeEntryConflicts.
@Test
void shouldMakeEntryConflicts() {
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, 2);
IndexEntryConflictException e = new IndexEntryConflictException(0L, 1L, value);
assertThat(e.evidenceMessage(tokens, schema)).isEqualTo("Both Node(0) and Node(1) have the label `label1` and property `p2` = 'hi'");
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaDescriptorTest method shouldCreateLabelDescriptors.
@Test
void shouldCreateLabelDescriptors() {
LabelSchemaDescriptor labelDesc;
labelDesc = SchemaDescriptor.forLabel(LABEL_ID, 1);
assertThat(labelDesc.getLabelId()).isEqualTo(LABEL_ID);
assertThat(labelDesc.entityType()).isEqualTo(EntityType.NODE);
assertThat(labelDesc.propertySchemaType()).isEqualTo(PropertySchemaType.COMPLETE_ALL_TOKENS);
assertArray(labelDesc.getPropertyIds(), 1);
labelDesc = SchemaDescriptor.forLabel(LABEL_ID, 1, 2, 3);
assertThat(labelDesc.getLabelId()).isEqualTo(LABEL_ID);
assertArray(labelDesc.getPropertyIds(), 1, 2, 3);
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaComplianceCheckerTest method shouldReportNotUniquelyIndexed.
@Test
void shouldReportNotUniquelyIndexed() throws Exception {
// given
LabelSchemaDescriptor descriptor = forLabel(label1, propertyKey1);
long indexId = uniqueIndex(descriptor);
long nodeId;
try (AutoCloseable ignored = tx()) {
TextValue value = stringValue("a");
// (N1) indexed w/ property A
{
long propId = propertyStore.nextId(CursorContext.NULL);
nodeId = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, value));
indexValue(descriptor, indexId, nodeId, value);
}
// (N2) indexed w/ property A
{
long propId = propertyStore.nextId(CursorContext.NULL);
long nodeId2 = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, value));
indexValue(descriptor, indexId, nodeId2, value);
}
}
// when
checkIndexed(nodeId);
// then
expect(ConsistencyReport.NodeConsistencyReport.class, report -> report.uniqueIndexNotUnique(any(), any(), anyLong()));
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaComplianceCheckerTest method shouldReportNotIndexed.
@Test
void shouldReportNotIndexed() throws Exception {
// given
LabelSchemaDescriptor descriptor = forLabel(label1, propertyKey1);
index(descriptor);
long nodeId;
try (AutoCloseable ignored = tx()) {
// (N1) w/ property A (NOT indexed)
long propId = propertyStore.nextId(CursorContext.NULL);
nodeId = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, stringValue("a")));
}
// when
checkIndexed(nodeId);
// then
expect(ConsistencyReport.NodeConsistencyReport.class, report -> report.notIndexed(any(), any()));
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldPopulateIndexWithOneNode.
@Test
void shouldPopulateIndexWithOneNode() throws Exception {
// GIVEN
String value = "Taylor";
long nodeId = createNode(map(name, value), FIRST);
IndexPopulator actualPopulator = indexPopulator(false);
TrackingIndexPopulator populator = new TrackingIndexPopulator(actualPopulator);
int label = tokenHolders.labelTokens().getIdByName(FIRST.name());
int prop = tokenHolders.propertyKeyTokens().getIdByName(name);
LabelSchemaDescriptor descriptor = SchemaDescriptor.forLabel(label, prop);
IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.NODE, IndexPrototype.forSchema(descriptor));
// WHEN
job.run();
// THEN
IndexEntryUpdate<?> update = IndexEntryUpdate.add(nodeId, descriptor, Values.of(value));
assertTrue(populator.created);
assertEquals(Collections.singletonList(update), populator.includedSamples);
assertEquals(1, populator.adds.size());
assertTrue(populator.resultSampled);
assertTrue(populator.closeCall);
}
Aggregations