Search in sources :

Example 26 with ReadOperations

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

the class KernelTransactionSecurityContextTest method shouldAllowReadsInFullMode.

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

Example 27 with ReadOperations

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

the class RelationshipCountsTest 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 28 with ReadOperations

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

the class DataStatementArgumentVerificationTest method shouldReturnNoPropertyFromNodeGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant.

@Test
public void shouldReturnNoPropertyFromNodeGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant() throws Exception {
    // given
    ReadOperations statement = stubStatement();
    // when
    Object value = statement.nodeGetProperty(17, StatementConstants.NO_SUCH_PROPERTY_KEY);
    // then
    assertNull("should return NoProperty", value);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 29 with ReadOperations

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

the class DataStatementArgumentVerificationTest method shouldReturnNoPropertyFromGraphGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant.

@Test
public void shouldReturnNoPropertyFromGraphGetPropertyWithoutDelegatingForNoSuchPropertyKeyIdConstant() throws Exception {
    // given
    ReadOperations statement = stubStatement();
    // when
    Object value = statement.graphGetProperty(StatementConstants.NO_SUCH_PROPERTY_KEY);
    // then
    assertNull("should return NoProperty", value);
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 30 with ReadOperations

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

the class MultiIndexPopulationConcurrentUpdatesIT method getLabelIdsByName.

private Map<String, Integer> getLabelIdsByName(String... names) {
    ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
    ReadOperations readOperations = transactionStatementContextBridge.get().readOperations();
    Map<String, Integer> labelNameIdMap = new HashMap<>();
    for (String name : names) {
        labelNameIdMap.put(name, readOperations.labelGetForName(name));
    }
    return labelNameIdMap;
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) HashMap(java.util.HashMap) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)

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