use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexIT method committedAndTransactionalIndexRulesShouldBeMerged.
@Test
void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception {
// GIVEN
SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction();
IndexDescriptor existingRule = schemaWriteOperations.indexCreate(schema, "my index");
commit();
// WHEN
KernelTransaction transaction = newTransaction(AUTH_DISABLED);
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyKeyId2);
IndexDescriptor addedRule = transaction.schemaWrite().indexCreate(schema, "my other index");
Set<IndexDescriptor> indexRulesInTx = asSet(transaction.schemaRead().indexesGetForLabel(labelId));
commit();
// THEN
assertEquals(asSet(existingRule, addedRule), indexRulesInTx);
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldPopulateIndexWithASmallDataset.
@Test
void shouldPopulateIndexWithASmallDataset() throws Exception {
// GIVEN
String value = "Mattias";
long node1 = createNode(map(name, value), FIRST);
createNode(map(name, value), SECOND);
createNode(map(age, 31), FIRST);
long node4 = createNode(map(age, 35, 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<?> update1 = add(node1, descriptor, Values.of(value));
IndexEntryUpdate<?> update2 = add(node4, descriptor, Values.of(value));
assertTrue(populator.created);
assertEquals(Arrays.asList(update1, update2), populator.includedSamples);
assertEquals(1, populator.adds.size());
assertTrue(populator.resultSampled);
assertTrue(populator.closeCall);
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SystemBuiltInProceduresIT method awaitIndex.
@Test
void awaitIndex() throws Throwable {
// Given
KernelTransaction transaction = newTransaction(AUTH_DISABLED);
int labelId1 = transaction.tokenWrite().labelGetOrCreateForName("Person");
int propertyKeyId1 = transaction.tokenWrite().propertyKeyGetOrCreateForName("foo");
LabelSchemaDescriptor personFooDescriptor = forLabel(labelId1, propertyKeyId1);
transaction.schemaWrite().indexCreate(personFooDescriptor, "person foo index");
commit();
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
// When & Then
// this will always be true because that procedure returns void BUT it proves that it runs on system
assertFalse(tx.execute("CALL db.awaitIndex('person foo index',10)").hasNext());
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaComplianceCheckerTest method shouldCheckIndexesWithLookupFiltering.
@Test
void shouldCheckIndexesWithLookupFiltering() throws Exception {
// given
LabelSchemaDescriptor descriptor = forLabel(label1, propertyKey1);
long indexId = uniqueIndex(descriptor);
long nodeId;
try (AutoCloseable ignored = tx()) {
PointValue value = pointValue(CoordinateReferenceSystem.WGS84, 2, 4);
// (N1) w/ property
{
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) w/ property
{
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 it should be successful
expect(ConsistencyReport.NodeConsistencyReport.class, report -> report.uniqueIndexNotUnique(any(), any(), anyLong()));
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class TransactionTestBase method shouldFreezeLockInteractions.
@Test
void shouldFreezeLockInteractions() throws Exception {
// GIVEN
int label;
int propertyKey;
LabelSchemaDescriptor schema;
try (KernelTransaction tx = beginTransaction()) {
label = tx.tokenWrite().labelGetOrCreateForName("Label");
propertyKey = tx.tokenWrite().propertyKeyGetOrCreateForName("prop");
schema = SchemaDescriptor.forLabel(label, propertyKey);
tx.schemaWrite().indexCreate(schema, "my index");
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
assertAllowedLocks(tx, schema);
// WHEN
tx.freezeLocks();
// THEN
assertFrozenLocks(tx, schema);
}
}
Aggregations