use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore.
@Test
public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore() throws Exception {
// given
final BatchTransactionApplier base = newApplier(false);
final BatchTransactionApplier indexApplier = newIndexApplier();
final BatchTransactionApplierFacade applier = new BatchTransactionApplierFacade(base, indexApplier);
final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
record.setInUse(false);
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)).updateRecord(record);
verify(indexingService, times(1)).dropIndex(rule);
verify(cacheAccess, times(1)).removeSchemaRuleFromCache(command.getKey());
}
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());
}
Aggregations