Search in sources :

Example 1 with ReadOperations

use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.

the class GraphDbStructureGuide method showStructure.

private void showStructure(Statement statement, DbStructureVisitor visitor) {
    ReadOperations read = statement.readOperations();
    try {
        showTokens(visitor, read);
        showSchema(visitor, read);
        showStatistics(visitor, read);
    } catch (KernelException e) {
        throw new IllegalStateException("Kernel exception when traversing database schema structure and statistics.  This is not expected to happen.", e);
    }
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) KernelException(org.neo4j.kernel.api.exceptions.KernelException)

Example 2 with ReadOperations

use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.

the class CompiledExpandUtilsTest method shouldUseGivenOrderIfItHasLowerDegreeWithTypes.

@Test
public void shouldUseGivenOrderIfItHasLowerDegreeWithTypes() throws EntityNotFoundException {
    // GIVEN
    ReadOperations readOperations = mock(ReadOperations.class);
    when(readOperations.nodeGetDegree(1L, Direction.OUTGOING, 1)).thenReturn(1);
    when(readOperations.nodeGetDegree(2L, Direction.INCOMING, 1)).thenReturn(3);
    // WHEN
    connectingRelationships(readOperations, 1L, Direction.OUTGOING, 2L, new int[] { 1 });
    // THEN
    verify(readOperations, times(1)).nodeGetRelationships(1L, Direction.OUTGOING, new int[] { 1 });
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 3 with ReadOperations

use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.

the class CompiledExpandUtilsTest method shouldSwitchOrderIfItHasLowerDegree.

@Test
public void shouldSwitchOrderIfItHasLowerDegree() throws EntityNotFoundException {
    // GIVEN
    ReadOperations readOperations = mock(ReadOperations.class);
    when(readOperations.nodeGetDegree(1L, Direction.OUTGOING)).thenReturn(3);
    when(readOperations.nodeGetDegree(2L, Direction.INCOMING)).thenReturn(1);
    // WHEN
    connectingRelationships(readOperations, 1L, Direction.OUTGOING, 2L);
    // THEN
    verify(readOperations, times(1)).nodeGetRelationships(2L, Direction.INCOMING);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 4 with ReadOperations

use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.

the class CompiledExpandUtilsTest method shouldUseGivenOrderIfItHasLowerDegree.

@Test
public void shouldUseGivenOrderIfItHasLowerDegree() throws EntityNotFoundException {
    // GIVEN
    ReadOperations readOperations = mock(ReadOperations.class);
    when(readOperations.nodeGetDegree(1L, Direction.OUTGOING)).thenReturn(1);
    when(readOperations.nodeGetDegree(2L, Direction.INCOMING)).thenReturn(3);
    // WHEN
    connectingRelationships(readOperations, 1L, Direction.OUTGOING, 2L);
    // THEN
    verify(readOperations, times(1)).nodeGetRelationships(1L, Direction.OUTGOING);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 5 with ReadOperations

use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.

the class CompiledExpandUtilsTest method shouldSwitchOrderIfItHasLowerDegreeWithTypes.

@Test
public void shouldSwitchOrderIfItHasLowerDegreeWithTypes() throws EntityNotFoundException {
    // GIVEN
    ReadOperations readOperations = mock(ReadOperations.class);
    when(readOperations.nodeGetDegree(1L, Direction.OUTGOING, 1)).thenReturn(3);
    when(readOperations.nodeGetDegree(2L, Direction.INCOMING, 1)).thenReturn(1);
    // WHEN
    connectingRelationships(readOperations, 1L, Direction.OUTGOING, 2L, new int[] { 1 });
    // THEN
    verify(readOperations, times(1)).nodeGetRelationships(2L, Direction.INCOMING, new int[] { 1 });
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Aggregations

ReadOperations (org.neo4j.kernel.api.ReadOperations)73 Test (org.junit.Test)52 Statement (org.neo4j.kernel.api.Statement)37 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)22 SchemaWriteOperations (org.neo4j.kernel.api.SchemaWriteOperations)9 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)8 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)7 NotFoundException (org.neo4j.graphdb.NotFoundException)5 Transaction (org.neo4j.graphdb.Transaction)5 HashMap (java.util.HashMap)4 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)4 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)4 DataWriteOperations (org.neo4j.kernel.api.DataWriteOperations)4 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)4 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)3 Label (org.neo4j.graphdb.Label)3 RelationshipType (org.neo4j.graphdb.RelationshipType)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3