Search in sources :

Example 51 with ReadOperations

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

the class DataStatementArgumentVerificationTest method shouldReturnEmptyIdIteratorFromNodesGetForLabelForNoSuchLabelConstant.

@Test
public void shouldReturnEmptyIdIteratorFromNodesGetForLabelForNoSuchLabelConstant() throws Exception {
    // given
    ReadOperations statement = stubStatement();
    // when
    PrimitiveLongIterator nodes = statement.nodesGetForLabel(StatementConstants.NO_SUCH_LABEL);
    // then
    assertFalse("should not contain any ids", nodes.hasNext());
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 52 with ReadOperations

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

the class KernelTransactionSecurityContextTest method shouldAllowReadsInWriteMode.

@Test
public void shouldAllowReadsInWriteMode() throws Throwable {
    // Given
    KernelTransactionImplementation tx = newTransaction(AnonymousContext.write());
    // When
    ReadOperations reads = tx.acquireStatement().readOperations();
    // Then
    assertNotNull(reads);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 53 with ReadOperations

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

the class CompositeCountsTest method countsForRelationship.

/**
     * @param start the label of the start node of relationships to get the number of, or {@code null} for "any".
     * @param type  the type of the relationships to get the number of, or {@code null} for "any".
     * @param end   the label of the end node of relationships to get the number of, or {@code null} for "any".
     */
private long countsForRelationship(Label start, RelationshipType type, Label end) {
    ReadOperations read = statementSupplier.get().readOperations();
    int startId, typeId, endId;
    // start
    if (start == null) {
        startId = ReadOperations.ANY_LABEL;
    } else {
        if (ReadOperations.NO_SUCH_LABEL == (startId = read.labelGetForName(start.name()))) {
            return 0;
        }
    }
    // type
    if (type == null) {
        typeId = ReadOperations.ANY_RELATIONSHIP_TYPE;
    } else {
        if (ReadOperations.NO_SUCH_LABEL == (typeId = read.relationshipTypeGetForName(type.name()))) {
            return 0;
        }
    }
    // end
    if (end == null) {
        endId = ReadOperations.ANY_LABEL;
    } else {
        if (ReadOperations.NO_SUCH_LABEL == (endId = read.labelGetForName(end.name()))) {
            return 0;
        }
    }
    return read.countsForRelationship(startId, typeId, endId);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations)

Example 54 with ReadOperations

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

the class LabelCountsTest method countsForNode.

/** @param label the label to get the number of nodes of, or {@code null} to get the total number of nodes. */
private long countsForNode(Label label) {
    ReadOperations read = statementSupplier.get().readOperations();
    int labelId;
    if (label == null) {
        labelId = ReadOperations.ANY_LABEL;
    } else {
        if (ReadOperations.NO_SUCH_LABEL == (labelId = read.labelGetForName(label.name()))) {
            return 0;
        }
    }
    return read.countsForNode(labelId);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations)

Example 55 with ReadOperations

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

the class DataStatementArgumentVerificationTest method shouldReturnNoPropertyFromRelationshipGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant.

@Test
public void shouldReturnNoPropertyFromRelationshipGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant() throws Exception {
    // given
    ReadOperations statement = stubStatement();
    // when
    Object value = statement.relationshipGetProperty(17, StatementConstants.NO_SUCH_PROPERTY_KEY);
    // then
    assertNull("should return NoProperty", value);
}
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