use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class LockingStatementOperationsTest method shouldAcquireSchemaWriteLockBeforeAddingIndexRule.
@Test
public void shouldAcquireSchemaWriteLockBeforeAddingIndexRule() throws Exception {
// given
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(123, 456);
NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel(123, 456);
when(schemaWriteOps.indexCreate(state, descriptor)).thenReturn(index);
// when
NewIndexDescriptor result = lockingOps.indexCreate(state, descriptor);
// then
assertSame(index, result);
order.verify(locks).acquireExclusive(LockTracer.NONE, ResourceTypes.SCHEMA, schemaResource());
order.verify(schemaWriteOps).indexCreate(state, descriptor);
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class IndexStatisticsTest method shouldNotSeeDataCreatedAfterPopulation.
@Test
public void shouldNotSeeDataCreatedAfterPopulation() throws KernelException {
// given
NewIndexDescriptor index = awaitOnline(createIndex("Person", "name"));
// when
createSomePersons();
// then
assertEquals(1.0d, indexSelectivity(index), DOUBLE_ERROR_TOLERANCE);
assertEquals(0L, indexSize(index));
assertEquals(4L, indexUpdates(index));
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class IndexStatisticsTest method shouldProvideIndexStatisticsForDataSeenDuringPopulationAndIgnoreDataCreatedAfterPopulation.
@Test
public void shouldProvideIndexStatisticsForDataSeenDuringPopulationAndIgnoreDataCreatedAfterPopulation() throws KernelException {
// given
createSomePersons();
NewIndexDescriptor index = awaitOnline(createIndex("Person", "name"));
// when
createSomePersons();
// then
assertEquals(0.75d, indexSelectivity(index), DOUBLE_ERROR_TOLERANCE);
assertEquals(4L, indexSize(index));
assertEquals(4L, indexUpdates(index));
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogTriggerSamplingOnAnIndexes.
@Test
public void shouldLogTriggerSamplingOnAnIndexes() throws Exception {
// given
long indexId = 0;
IndexSamplingMode mode = TRIGGER_REBUILD_ALL;
NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel(0, 1);
IndexingService indexingService = newIndexingServiceWithMockedDependencies(populator, accessor, withData(), IndexRule.indexRule(indexId, descriptor, PROVIDER_DESCRIPTOR));
life.init();
life.start();
// when
indexingService.triggerIndexSampling(descriptor.schema(), mode);
// then
String userDescription = descriptor.schema().userDescription(nameLookup);
logProvider.assertAtLeastOnce(logMatch.info("Manual trigger for sampling index " + userDescription + " [" + mode + "]"));
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class IndexStatisticsTest method shouldRemoveIndexStatisticsAfterIndexIsDeleted.
@Test
public void shouldRemoveIndexStatisticsAfterIndexIsDeleted() throws KernelException {
// given
createSomePersons();
NewIndexDescriptor index = awaitOnline(createIndex("Person", "name"));
SchemaStorage storage = new SchemaStorage(neoStores().getSchemaStore());
long indexId = storage.indexGetForSchema(index).getId();
// when
dropIndex(index);
// then
try {
indexSelectivity(index);
fail("Expected IndexNotFoundKernelException to be thrown");
} catch (IndexNotFoundKernelException e) {
DoubleLongRegister actual = getTracker().indexSample(indexId, Registers.newDoubleLongRegister());
assertDoubleLongEquals(0L, 0L, actual);
}
// and then index size and index updates are zero on disk
DoubleLongRegister actual = getTracker().indexUpdatesAndSize(indexId, Registers.newDoubleLongRegister());
assertDoubleLongEquals(0L, 0L, actual);
}
Aggregations