Search in sources :

Example 76 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class IndexStatisticsTest method shouldProvideIndexStatisticsWhenIndexIsBuiltViaPopulationAndConcurrentAdditions.

@Test
public void shouldProvideIndexStatisticsWhenIndexIsBuiltViaPopulationAndConcurrentAdditions() throws Exception {
    // given some initial data
    int initialNodes = repeatCreateNamedPeopleFor(NAMES.length * CREATION_MULTIPLIER).length;
    // when populating while creating
    NewIndexDescriptor index = createIndex("Person", "name");
    final UpdatesTracker updatesTracker = executeCreations(index, CREATION_MULTIPLIER);
    awaitOnline(index);
    // then
    int seenWhilePopulating = initialNodes + updatesTracker.createdDuringPopulation();
    double expectedSelectivity = UNIQUE_NAMES / seenWhilePopulating;
    assertCorrectIndexSelectivity(expectedSelectivity, indexSelectivity(index));
    assertCorrectIndexSize(seenWhilePopulating, indexSize(index));
    assertCorrectIndexUpdates(updatesTracker.createdAfterPopulation(), indexUpdates(index));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 77 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class IndexStatisticsTest method shouldProvideIndexStatisticsForDataCreatedWhenPopulationBeforeTheIndexIsOnline.

@Test
public void shouldProvideIndexStatisticsForDataCreatedWhenPopulationBeforeTheIndexIsOnline() throws KernelException {
    // given
    createSomePersons();
    // when
    NewIndexDescriptor index = awaitOnline(createIndex("Person", "name"));
    // then
    assertEquals(0.75d, indexSelectivity(index), DOUBLE_ERROR_TOLERANCE);
    assertEquals(4L, indexSize(index));
    assertEquals(0L, indexUpdates(index));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 78 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class IndexIT method addIndexRuleInATransaction.

@Test
public void addIndexRuleInATransaction() throws Exception {
    // GIVEN
    SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
    // WHEN
    NewIndexDescriptor expectedRule = schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
    commit();
    // THEN
    ReadOperations readOperations = readOperationsInNewTransaction();
    assertEquals(asSet(expectedRule), asSet(readOperations.indexesGetForLabel(labelId)));
    assertEquals(expectedRule, readOperations.indexGetForLabelAndPropertyKey(descriptor));
    commit();
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 79 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class IndexPopulationJobTest method newIndexPopulationJob.

private IndexPopulationJob newIndexPopulationJob(FailedIndexProxyFactory failureDelegateFactory, IndexPopulator populator, FlippableIndexProxy flipper, IndexStoreView storeView, LogProvider logProvider, boolean constraint) throws TransactionFailureException {
    NewIndexDescriptor descriptor = indexDescriptor(FIRST, name, constraint);
    long indexId = 0;
    flipper.setFlipTarget(mock(IndexProxyFactory.class));
    MultipleIndexPopulator multiPopulator = new MultipleIndexPopulator(storeView, logProvider);
    IndexPopulationJob job = new IndexPopulationJob(storeView, multiPopulator, NO_MONITOR, stateHolder::clear);
    job.addPopulator(populator, indexId, descriptor, PROVIDER_DESCRIPTOR, format(":%s(%s)", FIRST.name(), name), flipper, failureDelegateFactory);
    return job;
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)

Example 80 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class IndexPopulationJobTest method inMemoryPopulator.

private IndexPopulator inMemoryPopulator(boolean constraint) throws TransactionFailureException {
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
    NewIndexDescriptor descriptor = indexDescriptor(FIRST, name, constraint);
    return new InMemoryIndexProvider().getPopulator(21, descriptor, samplingConfig);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) InMemoryIndexProvider(org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider)

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