Search in sources :

Example 36 with NewIndexDescriptor

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

the class IndexIT method committedAndTransactionalIndexRulesShouldBeMerged.

@Test
public void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception {
    // GIVEN
    SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
    NewIndexDescriptor existingRule = schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
    commit();
    // WHEN
    Statement statement = statementInNewTransaction(AnonymousContext.AUTH_DISABLED);
    NewIndexDescriptor addedRule = statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(labelId, 10));
    Set<NewIndexDescriptor> indexRulesInTx = asSet(statement.readOperations().indexesGetForLabel(labelId));
    commit();
    // THEN
    assertEquals(asSet(existingRule, addedRule), indexRulesInTx);
}
Also used : SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 37 with NewIndexDescriptor

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

the class HaCountsIT method shouldUpdateCountsOnSlavesWhenCreatingAnIndexOnMaster.

@Test
public void shouldUpdateCountsOnSlavesWhenCreatingAnIndexOnMaster() throws Exception {
    // when creating a node on the master
    createANode(master, LABEL, PROPERTY_VALUE, PROPERTY_NAME);
    NewIndexDescriptor indexDescriptor = createAnIndex(master, LABEL, PROPERTY_NAME);
    long indexId = awaitOnline(master, indexDescriptor);
    // and the slaves got the updates
    cluster.sync(master);
    long index1 = awaitOnline(slave1, indexDescriptor);
    long index2 = awaitOnline(slave2, indexDescriptor);
    // then the slaves has updated counts
    assertOnIndexCounts(0, 1, 1, 1, indexId, master);
    assertOnIndexCounts(0, 1, 1, 1, index1, slave1);
    assertOnIndexCounts(0, 1, 1, 1, index2, slave2);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 38 with NewIndexDescriptor

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

the class HaCountsIT method shouldUpdateCountsOnClusterWhenCreatingANodeOnSlaveAndAnIndexOnMaster.

@Test
public void shouldUpdateCountsOnClusterWhenCreatingANodeOnSlaveAndAnIndexOnMaster() throws Exception {
    // when creating a node on the master
    createANode(slave1, LABEL, PROPERTY_VALUE, PROPERTY_NAME);
    NewIndexDescriptor indexDescriptor = createAnIndex(master, LABEL, PROPERTY_NAME);
    long indexId = awaitOnline(master, indexDescriptor);
    // and the updates are propagate in the cluster
    cluster.sync();
    long index1 = awaitOnline(slave1, indexDescriptor);
    long index2 = awaitOnline(slave2, indexDescriptor);
    // then the slaves has updated counts
    assertOnIndexCounts(0, 1, 1, 1, indexId, master);
    assertOnIndexCounts(0, 1, 1, 1, index1, slave1);
    assertOnIndexCounts(0, 1, 1, 1, index2, slave2);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 39 with NewIndexDescriptor

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

the class DumpCountsStore method visitIndexStatistics.

@Override
public void visitIndexStatistics(long indexId, long updates, long size) {
    NewIndexDescriptor index = indexes.get(indexId);
    out.printf("\tIndexStatistics[(%s {%s})]:\tupdates=%d, size=%d%n", label(index.schema().getLabelId()), propertyKeys(index.schema().getPropertyIds()), updates, size);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)

Example 40 with NewIndexDescriptor

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

the class DumpCountsStore method visitIndexSample.

@Override
public void visitIndexSample(long indexId, long unique, long size) {
    NewIndexDescriptor index = indexes.get(indexId);
    out.printf("\tIndexSample[(%s {%s})]:\tunique=%d, size=%d%n", label(index.schema().getLabelId()), propertyKeys(index.schema().getPropertyIds()), unique, size);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)

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