use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class TransactionTestBase method shouldThrowOnThawOfNotFrozenLocks.
@Test
void shouldThrowOnThawOfNotFrozenLocks() 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()) {
// WHEN
assertThrows(LocksNotFrozenException.class, tx::thawLocks);
// THEN
assertAllowedLocks(tx, schema);
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class TransactionTestBase method shouldThawLockInteractions.
@Test
void shouldThawLockInteractions() 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()) {
// WHEN
tx.freezeLocks();
tx.thawLocks();
// THEN
assertAllowedLocks(tx, schema);
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class GenericNativeIndexProviderTest method completeConfigurationMustNotOverrideExistingSettings.
@Test
void completeConfigurationMustNotOverrideExistingSettings() {
// Given
DatabaseIndexContext context = DatabaseIndexContext.builder(null, null, DEFAULT_DATABASE_NAME).build();
GenericNativeIndexProvider provider = new GenericNativeIndexProvider(context, IndexDirectoryStructure.NONE, null, Config.defaults());
Map<String, Value> existingSettings = new HashMap<>();
CoordinateReferenceSystem existingCrs = CoordinateReferenceSystem.Cartesian;
DoubleArray min = Values.doubleArray(new double[] { 0, 0 });
DoubleArray max = Values.doubleArray(new double[] { 1, 1 });
existingSettings.put(spatialMinSettingForCrs(existingCrs).getSettingName(), min);
existingSettings.put(spatialMaxSettingForCrs(existingCrs).getSettingName(), max);
IndexConfig existingIndexConfig = IndexConfig.with(existingSettings);
LabelSchemaDescriptor incompleteSchema = SchemaDescriptor.forLabel(1, 1);
IndexDescriptor incompleteDescriptor = IndexPrototype.forSchema(incompleteSchema, IndexProviderDescriptor.UNDECIDED).withName("index").materialise(1).withIndexConfig(existingIndexConfig);
// When
IndexDescriptor completedDescriptor = provider.completeConfiguration(incompleteDescriptor);
// Then
IndexConfig completedIndexConfig = completedDescriptor.getIndexConfig();
for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
if (crs.equals(existingCrs)) {
// Assert value
assertEquals(min, completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
assertEquals(max, completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
} else {
// Simply assert not null
assertNotNull(completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
assertNotNull(completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
}
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class GenericNativeIndexProviderTest method mustCompleteIndexDescriptorConfigurationsWithSpatialConfig.
@Test
void mustCompleteIndexDescriptorConfigurationsWithSpatialConfig() {
// Given
DatabaseIndexContext context = DatabaseIndexContext.builder(null, null, DEFAULT_DATABASE_NAME).build();
GenericNativeIndexProvider provider = new GenericNativeIndexProvider(context, IndexDirectoryStructure.NONE, null, Config.defaults());
LabelSchemaDescriptor incompleteSchema = SchemaDescriptor.forLabel(1, 1);
IndexDescriptor incompleteDescriptor = IndexPrototype.forSchema(incompleteSchema, IndexProviderDescriptor.UNDECIDED).withName("index").materialise(1);
// When
IndexDescriptor completedDescriptor = provider.completeConfiguration(incompleteDescriptor);
// Then
IndexConfig sinfulIndexConfig = incompleteDescriptor.getIndexConfig();
IndexConfig completedIndexConfig = completedDescriptor.getIndexConfig();
assertEquals(0, sinfulIndexConfig.entries().count(p -> true), "expected sinful index config to have no entries");
for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
assertNotNull(completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
assertNotNull(completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class TxStateTest method shouldDifferentiateBetweenUniquenessConstraintsForDifferentLabels.
@Test
void shouldDifferentiateBetweenUniquenessConstraintsForDifferentLabels() {
// when
LabelSchemaDescriptor schema1 = forLabel(1, 17);
UniquenessConstraintDescriptor constraint1 = ConstraintDescriptorFactory.uniqueForSchema(schema1);
state.constraintDoAdd(constraint1, IndexPrototype.uniqueForSchema(schema1).withName("constraint_7").materialise(7));
LabelSchemaDescriptor schema2 = forLabel(2, 17);
UniquenessConstraintDescriptor constraint2 = ConstraintDescriptorFactory.uniqueForSchema(schema2);
state.constraintDoAdd(constraint2, IndexPrototype.uniqueForSchema(schema2).withName("constraint_19").materialise(19));
// then
assertEquals(singleton(constraint1), state.constraintsChangesForLabel(1).getAdded());
assertEquals(singleton(constraint2), state.constraintsChangesForLabel(2).getAdded());
}
Aggregations