use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan.
@Test
void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws IndexEntryConflictException, FlipFailedKernelException {
// given
createIndexPopulator();
multipleIndexPopulator.create(NULL);
IndexUpdater updater = mock(IndexUpdater.class);
IndexPopulator populator = createIndexPopulator(updater);
IndexUpdater indexUpdater = mock(IndexUpdater.class);
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(1, 1);
addPopulator(populator, 1);
// when external updates comes in
ValueIndexEntryUpdate<LabelSchemaDescriptor> lowUpdate = IndexEntryUpdate.add(10, schema, intValue(99));
ValueIndexEntryUpdate<LabelSchemaDescriptor> highUpdate = IndexEntryUpdate.add(20, schema, intValue(101));
multipleIndexPopulator.queueConcurrentUpdate(lowUpdate);
multipleIndexPopulator.queueConcurrentUpdate(highUpdate);
// and we ask to apply them, given an entity in between the two
multipleIndexPopulator.applyExternalUpdates(15);
// then only the lower one should be applied, the higher one ignored
verify(populator, times(1)).newPopulatingUpdater(any(), any());
verify(updater).process(lowUpdate);
verify(updater, never()).process(highUpdate);
verify(indexUpdater, never()).process(any(IndexEntryUpdate.class));
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldSeeIndexFromTransaction.
@Test
void shouldSeeIndexFromTransaction() throws Exception {
try (KernelTransaction transaction = beginTransaction()) {
transaction.schemaWrite().indexCreate(forLabel(label, prop1), "my index");
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
LabelSchemaDescriptor schema = forLabel(label, prop2);
transaction.schemaWrite().indexCreate(schema, "my other index");
SchemaRead schemaRead = transaction.schemaRead();
IndexDescriptor index = single(schemaRead.index(schema));
assertThat(index.schema().getPropertyIds()).isEqualTo(new int[] { prop2 });
assertThat(2).isEqualTo(Iterators.asList(schemaRead.indexesGetAll()).size());
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexCreateIT method shouldCreateWithSpecificExistingProviderName.
protected void shouldCreateWithSpecificExistingProviderName(IndexCreator creator) throws KernelException {
int counter = 0;
for (GraphDatabaseSettings.SchemaIndex indexSetting : GraphDatabaseSettings.SchemaIndex.values()) {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int labelId = tokenWrite.labelGetOrCreateForName("Label" + counter);
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
LabelSchemaDescriptor descriptor = forLabel(labelId, propId);
String provider = indexSetting.providerName();
String indexName = "index-" + counter;
creator.create(schemaWrite, descriptor, provider, indexName);
IndexDescriptor index = transaction.kernelTransaction().schemaRead().indexGetForName(indexName);
// when
commit();
// then
assertEquals(provider, indexingService.getIndexProxy(index).getDescriptor().getIndexProvider().name());
counter++;
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method getIndexReader.
private ValueIndexReader getIndexReader(int propertyId, Integer countryLabelId) throws IndexNotFoundKernelException {
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(countryLabelId, propertyId);
IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
return indexService.getIndexProxy(index).newValueReader();
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaStorageIT method makeIndexRuleForConstraint.
private IndexDescriptor makeIndexRuleForConstraint(long ruleId, String label, String propertyKey, long constraintId) {
LabelSchemaDescriptor schema = forLabel(labelId(label), propId(propertyKey));
IndexPrototype prototype = uniqueForSchema(schema, GenericNativeIndexProvider.DESCRIPTOR);
UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForSchema(schema);
prototype = prototype.withName(SchemaRule.generateName(constraint, new String[] { label }, new String[] { propertyKey }));
return prototype.materialise(ruleId).withOwningConstraintId(constraintId);
}
Aggregations