use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SystemBuiltInProceduresIT method resampleIndex.
@Test
void resampleIndex() 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.resampleIndex('person foo index')").hasNext());
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SystemBuiltInProceduresIT method awaitEventuallyConsistentIndexRefresh.
@Test
void awaitEventuallyConsistentIndexRefresh() 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.index.fulltext.awaitEventuallyConsistentIndexRefresh").hasNext());
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SystemBuiltInProceduresIT method resampleOutdatedIndexes.
@Test
void resampleOutdatedIndexes() 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.resampleOutdatedIndexes").hasNext());
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class NodeGetUniqueFromIndexSeekIT method createUniquenessConstraint.
private IndexDescriptor createUniquenessConstraint(int labelId, int... propertyIds) throws Exception {
KernelTransaction transaction = newTransaction(LoginContext.AUTH_DISABLED);
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyIds);
ConstraintDescriptor constraint = transaction.schemaWrite().uniquePropertyConstraintCreate(IndexPrototype.uniqueForSchema(schema));
IndexDescriptor index = transaction.schemaRead().indexGetForName(constraint.getName());
commit();
return index;
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexIT method shouldListConstraintIndexesInTheCoreAPI.
@Test
void shouldListConstraintIndexesInTheCoreAPI() throws Exception {
// given
KernelTransaction transaction = newTransaction(AUTH_DISABLED);
long initialIndexCount = Iterators.count(transaction.schemaRead().indexesGetAll());
int labelId = transaction.tokenWrite().labelGetOrCreateForName("Label1");
int propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName("property1");
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyKeyId);
transaction.schemaWrite().uniquePropertyConstraintCreate(uniqueForSchema(schema).withName("constraint name"));
commit();
// when
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
// then
Set<IndexDefinition> indexes = Iterables.asSet(tx.schema().getIndexes());
assertThat(indexes.size()).isEqualTo(initialIndexCount + 1);
IndexDefinition index = tx.schema().getIndexByName("constraint name");
assertThat(index.getLabels()).map(Label::name).containsOnly("Label1");
assertThat(index.getPropertyKeys()).containsOnly("property1");
assertTrue(index.isConstraintIndex(), "index should be a constraint index");
// when
var e = assertThrows(IllegalStateException.class, index::drop);
assertEquals("Constraint indexes cannot be dropped directly, instead drop the owning uniqueness constraint.", e.getMessage());
}
}
Aggregations