use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NativeNonUniqueIndexPopulatorTest method updaterShouldApplyDuplicateValues.
@Test
void updaterShouldApplyDuplicateValues() throws Exception {
// given
populator.create();
ValueIndexEntryUpdate<IndexDescriptor>[] updates = valueCreatorUtil.someUpdatesWithDuplicateValues(random);
try (IndexUpdater updater = populator.newPopulatingUpdater(null_property_accessor, NULL)) {
// when
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
updater.process(update);
}
}
// then
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
populator.close(true, NULL);
valueUtil.verifyUpdates(updates, this::getTree);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NativeIndexProviderTest method shouldNotCheckConflictsWhenApplyingUpdatesInOnlineAccessor.
@Test
void shouldNotCheckConflictsWhenApplyingUpdatesInOnlineAccessor() throws IOException, IndexEntryConflictException {
// given
Value someValue = Values.of(1);
provider = newProvider();
// when
IndexDescriptor descriptor = descriptorUnique();
try (IndexAccessor accessor = provider.getOnlineAccessor(descriptor, samplingConfig(), tokenNameLookup);
IndexUpdater indexUpdater = accessor.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
indexUpdater.process(IndexEntryUpdate.add(1, descriptor.schema(), someValue));
// then
// ... expect no failure on duplicate value
indexUpdater.process(IndexEntryUpdate.add(2, descriptor.schema(), someValue));
}
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatorTest method setUp.
@BeforeEach
void setUp() {
Path folder = testDir.directory("folder");
PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(dirFactory, fileSystem, folder);
IndexDescriptor descriptor = IndexPrototype.forSchema(labelSchemaDescriptor).withName("index").materialise(13);
index = LuceneSchemaIndexBuilder.create(descriptor, writable(), Config.defaults()).withIndexStorage(indexStorage).build();
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class IndexTransactionApplierFactoryTest method shouldRegisterIndexesToActivateIntoTheActivator.
@Test
void shouldRegisterIndexesToActivateIntoTheActivator() throws Exception {
// given
IndexUpdateListener indexUpdateListener = mock(IndexUpdateListener.class);
IndexActivator indexActivator = new IndexActivator(indexUpdateListener);
long indexId1 = 1;
long indexId2 = 2;
long indexId3 = 3;
long constraintId1 = 10;
long constraintId2 = 11;
long constraintId3 = 12;
String providerKey = "index-key";
String providerVersion = "v1";
IndexDescriptor rule1 = uniqueForSchema(forLabel(1, 1), providerKey, providerVersion, indexId1, constraintId1);
IndexDescriptor rule2 = uniqueForSchema(forLabel(2, 1), providerKey, providerVersion, indexId2, constraintId2);
IndexDescriptor rule3 = uniqueForSchema(forLabel(3, 1), providerKey, providerVersion, indexId3, constraintId3);
IndexTransactionApplierFactory applier = new IndexTransactionApplierFactory(indexUpdateListener);
var batchContext = mock(BatchContext.class);
when(batchContext.getLockGroup()).thenReturn(new LockGroup());
when(batchContext.indexUpdates()).thenReturn(mock(IndexUpdates.class));
when(batchContext.getIndexActivator()).thenReturn(indexActivator);
try (var txApplier = applier.startTx(new GroupOfCommands(), batchContext)) {
// activate index 1
txApplier.visitSchemaRuleCommand(new Command.SchemaRuleCommand(new SchemaRecord(rule1.getId()), asSchemaRecord(rule1, true), rule1));
// activate index 2
txApplier.visitSchemaRuleCommand(new Command.SchemaRuleCommand(new SchemaRecord(rule2.getId()), asSchemaRecord(rule2, true), rule2));
// activate index 3
txApplier.visitSchemaRuleCommand(new Command.SchemaRuleCommand(new SchemaRecord(rule3.getId()), asSchemaRecord(rule3, true), rule3));
// drop index 2
txApplier.visitSchemaRuleCommand(new Command.SchemaRuleCommand(asSchemaRecord(rule2, true), asSchemaRecord(rule2, false), rule2));
}
verify(indexUpdateListener).dropIndex(rule2);
indexActivator.close();
verify(indexUpdateListener).activateIndex(rule1);
verify(indexUpdateListener).activateIndex(rule3);
verifyNoMoreInteractions(indexUpdateListener);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NeoTransactionIndexApplierTest method shouldCreateIndexGivenCreateSchemaRuleCommand.
@Test
void shouldCreateIndexGivenCreateSchemaRuleCommand() throws Exception {
// Given
IndexDescriptor indexRule = indexRule(1, 42, 42);
IndexTransactionApplierFactory applier = newIndexTransactionApplier();
SchemaRecord before = new SchemaRecord(1);
SchemaRecord after = before.copy().initialize(true, 39);
after.setCreated();
Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(before, after, indexRule);
// When
boolean result;
try (TransactionApplier txApplier = applier.startTx(transactionToApply, batchContext)) {
result = txApplier.visitSchemaRuleCommand(command);
}
// Then
assertFalse(result);
verify(indexingService).createIndexes(SYSTEM, indexRule);
}
Aggregations