Search in sources :

Example 71 with NewIndexDescriptor

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);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) LabelSchemaDescriptor(org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor) Test(org.junit.Test)

Example 72 with NewIndexDescriptor

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));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 73 with NewIndexDescriptor

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));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 74 with NewIndexDescriptor

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 + "]"));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) IndexSamplingMode(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 75 with NewIndexDescriptor

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);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) SchemaStorage(org.neo4j.kernel.impl.store.SchemaStorage) DoubleLongRegister(org.neo4j.register.Register.DoubleLongRegister) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) Test(org.junit.Test)

Aggregations

NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)99 Test (org.junit.Test)55 Statement (org.neo4j.kernel.api.Statement)24 ReadOperations (org.neo4j.kernel.api.ReadOperations)17 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)10 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)9 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)9 InternalIndexState (org.neo4j.kernel.api.index.InternalIndexState)7 Transaction (org.neo4j.graphdb.Transaction)6 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)5 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)5 SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)5 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)4 Label (org.neo4j.graphdb.Label)4 NotFoundException (org.neo4j.graphdb.NotFoundException)4 KernelException (org.neo4j.kernel.api.exceptions.KernelException)4 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)4