Search in sources :

Example 11 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class AnyValueComparatorTest method shouldTernaryCompareNodes.

@Test
void shouldTernaryCompareNodes() {
    assertTernaryCompare(nodeValue(42, stringArray("L"), EMPTY_MAP), nodeValue(42, stringArray("L"), EMPTY_MAP), EQUAL);
    assertTernaryCompare(nodeValue(42, stringArray("L"), EMPTY_MAP), nodeValue(43, stringArray("L"), EMPTY_MAP), SMALLER_THAN);
    assertTernaryCompare(node(42), nodeValue(42, stringArray("L"), EMPTY_MAP), EQUAL);
    assertTernaryCompare(nodeValue(42, stringArray("L"), EMPTY_MAP), intValue(42), UNDEFINED);
    MapValue propMap = map("foo", "bar");
    assertTernaryCompare(nodeValue(42, stringArray("L"), propMap), propMap, UNDEFINED);
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 12 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class FabricKernelTransaction method makeChildTransactionalContext.

private TransactionalContext makeChildTransactionalContext(StatementLifecycle lifecycle) {
    var parentQuery = lifecycle.getMonitoredQuery();
    if (lifecycle.isParentChildMonitoringMode()) {
        // Cypher engine reports separately for each child query
        String queryText = "Internal query for parent query id: " + parentQuery.id();
        MapValue params = MapValue.EMPTY;
        return transactionalContextFactory.newContext(internalTransaction, queryText, params);
    } else {
        // Mark query as no longer in Fabric phase
        lifecycle.doneFabricPhase();
        // Cypher engine reports directly to parent query
        return transactionalContextFactory.newContextForQuery(internalTransaction, parentQuery);
    }
}
Also used : MapValue(org.neo4j.values.virtual.MapValue)

Example 13 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class NodeEntityWrappingNodeValue method properties.

public MapValue properties(NodeCursor nodeCursor, PropertyCursor propertyCursor) {
    MapValue m = properties;
    if (m == null) {
        try {
            synchronized (this) {
                m = properties;
                if (m == null) {
                    // No DBHits for Virtual node hacks.
                    var nodeProperties = node instanceof NodeEntity ? ((NodeEntity) node).getAllProperties(nodeCursor, propertyCursor) : node.getAllProperties();
                    m = properties = ValueUtils.asMapValue(nodeProperties);
                }
            }
        } catch (NotFoundException | IllegalStateException | StoreFailureException e) {
            throw new ReadAndDeleteTransactionConflictException(NodeEntity.isDeletedInCurrentTransaction(node), e);
        }
    }
    return m;
}
Also used : StoreFailureException(org.neo4j.exceptions.StoreFailureException) NotFoundException(org.neo4j.graphdb.NotFoundException) MapValue(org.neo4j.values.virtual.MapValue) NodeEntity(org.neo4j.kernel.impl.core.NodeEntity)

Example 14 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class RelationshipEntityWrappingValue method properties.

public MapValue properties(PropertyCursor propertyCursor) {
    MapValue m = properties;
    if (m == null) {
        try {
            synchronized (this) {
                m = properties;
                if (m == null) {
                    var relProperties = relationship instanceof RelationshipEntity ? ((RelationshipEntity) relationship).getAllProperties(propertyCursor) : relationship.getAllProperties();
                    m = properties = ValueUtils.asMapValue(relProperties);
                }
            }
        } catch (NotFoundException | IllegalStateException e) {
            throw new ReadAndDeleteTransactionConflictException(RelationshipEntity.isDeletedInCurrentTransaction(relationship), e);
        }
    }
    return m;
}
Also used : NotFoundException(org.neo4j.graphdb.NotFoundException) MapValue(org.neo4j.values.virtual.MapValue) RelationshipEntity(org.neo4j.kernel.impl.core.RelationshipEntity)

Example 15 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class RelationshipEntityWrappingValue method writeTo.

@Override
public <E extends Exception> void writeTo(AnyValueWriter<E> writer) throws E {
    if (writer.entityMode() == REFERENCE) {
        writer.writeRelationshipReference(id());
    } else {
        if (relationship instanceof RelationshipEntity) {
            RelationshipEntity proxy = (RelationshipEntity) relationship;
            if (!proxy.initializeData()) {
                // and that they need to retry it.
                throw new ReadAndDeleteTransactionConflictException(RelationshipEntity.isDeletedInCurrentTransaction(relationship));
            }
        }
        MapValue p;
        try {
            p = properties();
        } catch (ReadAndDeleteTransactionConflictException e) {
            if (!e.wasDeletedInThisTransaction()) {
                throw e;
            }
            // If it isn't a transient error then the relationship was deleted in the current transaction and we should write an 'empty' relationship.
            p = VirtualValues.EMPTY_MAP;
        }
        if (id() < 0) {
            writer.writeVirtualRelationshipHack(relationship);
        }
        writer.writeRelationship(id(), startNode().id(), endNode().id(), type(), p);
    }
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) RelationshipEntity(org.neo4j.kernel.impl.core.RelationshipEntity)

Aggregations

MapValue (org.neo4j.values.virtual.MapValue)48 Test (org.junit.jupiter.api.Test)30 AnyValue (org.neo4j.values.AnyValue)7 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)6 QueryExecution (org.neo4j.kernel.impl.query.QueryExecution)6 BoltAdapterSubscriber (org.neo4j.bolt.runtime.statemachine.impl.BoltAdapterSubscriber)5 QueryStatistics (org.neo4j.graphdb.QueryStatistics)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)3 ValueUtils.asMapValue (org.neo4j.kernel.impl.util.ValueUtils.asMapValue)3 Clock (java.time.Clock)2 LocalDate (java.time.LocalDate)2 HashMap (java.util.HashMap)2 SuccessMessage (org.neo4j.bolt.v3.messaging.response.SuccessMessage)2 NotFoundException (org.neo4j.graphdb.NotFoundException)2 RelationshipEntity (org.neo4j.kernel.impl.core.RelationshipEntity)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 DateTimeException (java.time.DateTimeException)1