use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class NeoTransactionIndexApplierTest method shouldCreateIndexGivenCreateSchemaRuleCommand.
@Test
public void shouldCreateIndexGivenCreateSchemaRuleCommand() throws Exception {
// Given
final IndexRule indexRule = indexRule(1, 42, 42, INDEX_DESCRIPTOR);
final IndexBatchTransactionApplier applier = newIndexTransactionApplier();
final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(emptyDynamicRecords, singleton(createdDynamicRecord(1)), indexRule);
// When
boolean result;
try (TransactionApplier txApplier = applier.startTx(transactionToApply)) {
result = txApplier.visitSchemaRuleCommand(command);
}
// Then
assertFalse(result);
verify(indexingService).createIndexes(indexRule);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class NeoTransactionIndexApplierTest method shouldDropIndexGivenDropSchemaRuleCommand.
@Test
public void shouldDropIndexGivenDropSchemaRuleCommand() throws Exception {
// Given
final IndexRule indexRule = indexRule(1, 42, 42, INDEX_DESCRIPTOR);
final IndexBatchTransactionApplier applier = newIndexTransactionApplier();
final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(singleton(createdDynamicRecord(1)), singleton(dynamicRecord(1, false)), indexRule);
// When
boolean result;
try (TransactionApplier txApplier = applier.startTx(transactionToApply)) {
result = txApplier.visitSchemaRuleCommand(command);
}
// Then
assertFalse(result);
verify(indexingService).dropIndex(indexRule);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyCreateIndexRuleSchemaRuleCommandToTheStoreInRecovery.
@Test
public void shouldApplyCreateIndexRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception {
// given
final BatchTransactionApplier applier = newApplierFacade(newIndexApplier(), newApplier(true));
final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
record.setCreated();
final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
final IndexRule rule = indexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"));
final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(schemaStore, times(1)).setHighestPossibleIdInUse(record.getId());
verify(schemaStore, times(1)).updateRecord(record);
verify(indexingService, times(1)).createIndexes(rule);
verify(cacheAccess, times(1)).addSchemaRule(rule);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method testManualIndexPopulation.
@Test
public void testManualIndexPopulation() throws IOException, IndexNotFoundKernelException, InterruptedException {
IndexingService indexingService = getIndexingService(database);
SchemaStore schemaStore = getSchemaStore(database);
LabelTokenHolder labelTokenHolder = getLabelTokenHolder(database);
PropertyKeyTokenHolder propertyKeyTokenHolder = getPropertyKeyTokenHolder(database);
int foodId = labelTokenHolder.getIdByName(FOOD_LABEL);
int propertyId = propertyKeyTokenHolder.getIdByName(PROPERTY_NAME);
IndexRule rule = IndexRule.indexRule(schemaStore.nextId(), NewIndexDescriptorFactory.forLabel(foodId, propertyId), indexDescriptor);
indexingService.createIndexes(rule);
IndexProxy indexProxy = indexingService.getIndexProxy(rule.getId());
waitIndexOnline(indexProxy);
assertEquals(InternalIndexState.ONLINE, indexProxy.getState());
PopulationProgress progress = indexProxy.getIndexPopulationProgress();
assertEquals(progress.getCompleted(), progress.getTotal());
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class IndexingServiceTest method shouldCreateMultipleIndexesInOneCall.
@Test
public void shouldCreateMultipleIndexesInOneCall() throws Exception {
// GIVEN
IndexingService.Monitor monitor = IndexingService.NO_MONITOR;
IndexingService indexing = newIndexingServiceWithMockedDependencies(populator, accessor, withData(addNodeUpdate(0, "value", 1)), monitor);
life.start();
// WHEN
IndexRule indexRule1 = indexRule(0, 0, 0, PROVIDER_DESCRIPTOR);
IndexRule indexRule2 = indexRule(1, 0, 1, PROVIDER_DESCRIPTOR);
IndexRule indexRule3 = indexRule(2, 1, 0, PROVIDER_DESCRIPTOR);
indexing.createIndexes(indexRule1, indexRule2, indexRule3);
// THEN
verify(indexProvider).getPopulator(eq(0L), eq(NewIndexDescriptorFactory.forLabel(0, 0)), any(IndexSamplingConfig.class));
verify(indexProvider).getPopulator(eq(1L), eq(NewIndexDescriptorFactory.forLabel(0, 1)), any(IndexSamplingConfig.class));
verify(indexProvider).getPopulator(eq(2L), eq(NewIndexDescriptorFactory.forLabel(1, 0)), any(IndexSamplingConfig.class));
waitForIndexesToComeOnline(indexing, 0, 1, 2);
}
Aggregations