Search in sources :

Example 1 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class IndexProviderTests method shouldReportInitialStateAsPopulatingIfPopulationStartedButIncomplete.

@Test
void shouldReportInitialStateAsPopulatingIfPopulationStartedButIncomplete() throws IOException {
    // given
    provider = newProvider();
    IndexPopulator populator = provider.getPopulator(descriptor(), samplingConfig(), heapBufferFactory(1024), INSTANCE, tokenNameLookup);
    populator.create();
    // when
    InternalIndexState state = provider.getInitialState(descriptor(), NULL);
    // then
    assertEquals(InternalIndexState.POPULATING, state);
    populator.close(true, NULL);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) Test(org.junit.jupiter.api.Test)

Example 2 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsMustNotIncludeIndexBackedConstraintsWithFailedIndexIndex.

@Test
void schemaStatementsMustNotIncludeIndexBackedConstraintsWithFailedIndexIndex() throws IndexNotFoundKernelException, ProcedureException {
    IndexDescriptor index = someOrphanedIndex();
    ConstraintDescriptor constraint = indexBackedConstraint(index);
    index = indexBoundToConstraint(index, constraint);
    InternalIndexState internalIndexState = InternalIndexState.FAILED;
    SchemaReadCore schemaReadCore = getSchemaReadCore(constraint, index, internalIndexState);
    TokenRead tokenRead = mock(TokenRead.class);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    assertEquals(0, result.size());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Example 3 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsMustNotIncludeOrphanedIndexes.

@Test
void schemaStatementsMustNotIncludeOrphanedIndexes() throws IndexNotFoundKernelException, ProcedureException {
    IndexDescriptor index = someOrphanedIndex();
    InternalIndexState indexState = InternalIndexState.ONLINE;
    SchemaReadCore schemaReadCore = getSchemaReadCore(index, indexState);
    TokenRead tokenRead = mock(TokenRead.class);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    assertEquals(0, result.size());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Example 4 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsShouldHandleIndexWithBackticks.

@Test
void schemaStatementsShouldHandleIndexWithBackticks() throws IndexNotFoundKernelException, ProcedureException, LabelNotFoundKernelException, PropertyKeyIdNotFoundKernelException {
    IndexDescriptor index = forSchema(forLabel(1, 1)).withName(NAME_WITH_BACKTICKS).materialise(1);
    InternalIndexState internalIndexState = InternalIndexState.ONLINE;
    SchemaReadCore schemaReadCore = getSchemaReadCore(index, internalIndexState);
    TokenRead tokenRead = mock(TokenRead.class);
    when(tokenRead.nodeLabelName(1)).thenReturn(LABEL_WITH_BACKTICKS);
    when(tokenRead.propertyKeyName(1)).thenReturn(PROPERTY_KEY_WITH_BACKTICKS);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    Iterator<BuiltInProcedures.SchemaStatementResult> iter = result.iterator();
    assertTrue(iter.hasNext());
    BuiltInProcedures.SchemaStatementResult next = iter.next();
    assertEquals(NAME_WITH_BACKTICKS, next.name);
    assertEquals(format("CALL db.createIndex('%s', ['%s'], ['%s'], 'Undecided-0', {})", NAME_WITH_BACKTICKS, LABEL_WITH_BACKTICKS, PROPERTY_KEY_WITH_BACKTICKS), next.createStatement);
    assertEquals(format("DROP INDEX %s", ESCAPED_NAME_WITH_BACKTICKS), next.dropStatement);
    assertFalse(iter.hasNext());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Example 5 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsMustNotIncludeFailedIndexes.

@Test
void schemaStatementsMustNotIncludeFailedIndexes() throws IndexNotFoundKernelException, ProcedureException {
    IndexDescriptor index = someIndex();
    InternalIndexState indexState = InternalIndexState.FAILED;
    SchemaReadCore schemaReadCore = getSchemaReadCore(index, indexState);
    TokenRead tokenRead = mock(TokenRead.class);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    assertEquals(0, result.size());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Aggregations

InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)25 Test (org.junit.jupiter.api.Test)17 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)16 SchemaReadCore (org.neo4j.internal.kernel.api.SchemaReadCore)7 TokenRead (org.neo4j.internal.kernel.api.TokenRead)7 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)7 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)5 ArrayList (java.util.ArrayList)3 EnumMap (java.util.EnumMap)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 MutableLongObjectMap (org.eclipse.collections.api.map.primitive.MutableLongObjectMap)3 LongObjectHashMap (org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap)3 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 String.format (java.lang.String.format)2 Path (java.nio.file.Path)2 Arrays (java.util.Arrays)2