Search in sources :

Example 16 with AnyValue

use of org.neo4j.values.AnyValue in project neo4j by neo4j.

the class BuiltInDbmsProceduresIT method listAllCapabilities.

@Test
void listAllCapabilities() throws KernelException {
    QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
    int procedureId = procs().procedureGet(procedureName).id();
    RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
    List<AnyValue[]> capabilities = asList(callResult);
    List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
    assertThat(capabilityNames).containsExactlyInAnyOrder(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_custom_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName());
}
Also used : AnyValue(org.neo4j.values.AnyValue) Arrays(java.util.Arrays) Label(org.neo4j.graphdb.Label) RawIterator(org.neo4j.collection.RawIterator) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) Iterators.asList(org.neo4j.internal.helpers.collection.Iterators.asList) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) ProcedureSignature.procedureName(org.neo4j.internal.kernel.api.procs.ProcedureSignature.procedureName) Public(org.neo4j.annotations.Public) Values(org.neo4j.values.storable.Values) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CapabilitiesRegistry(org.neo4j.capabilities.CapabilitiesRegistry) Capability(org.neo4j.capabilities.Capability) CapabilitiesSettings(org.neo4j.capabilities.CapabilitiesSettings) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FALSE(org.neo4j.configuration.SettingValueParsers.FALSE) CapabilityProviderContext(org.neo4j.capabilities.CapabilityProviderContext) INTEGER(org.neo4j.capabilities.Type.INTEGER) DOUBLE(org.neo4j.capabilities.Type.DOUBLE) CapabilityProvider(org.neo4j.capabilities.CapabilityProvider) Name(org.neo4j.capabilities.Name) DBMSCapabilities(org.neo4j.capabilities.DBMSCapabilities) BooleanValue(org.neo4j.values.storable.BooleanValue) BOOLEAN(org.neo4j.capabilities.Type.BOOLEAN) TextValue(org.neo4j.values.storable.TextValue) Label.label(org.neo4j.graphdb.Label.label) Values.stringValue(org.neo4j.values.storable.Values.stringValue) Collectors(java.util.stream.Collectors) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) Test(org.junit.jupiter.api.Test) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) List(java.util.List) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) ArrayUtils.toArray(org.apache.commons.lang3.ArrayUtils.toArray) Description(org.neo4j.configuration.Description) KernelException(org.neo4j.exceptions.KernelException) Matchers.contains(org.hamcrest.Matchers.contains) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CapabilityDeclaration(org.neo4j.capabilities.CapabilityDeclaration) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest) TextValue(org.neo4j.values.storable.TextValue) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 17 with AnyValue

use of org.neo4j.values.AnyValue in project neo4j by neo4j.

the class RecordMessageEncoder method encode.

@Override
public void encode(Neo4jPack.Packer packer, RecordMessage message) throws IOException {
    AnyValue[] fields = message.fields();
    packer.packStructHeader(1, message.signature());
    packer.packListHeader(fields.length);
    for (AnyValue field : fields) {
        packer.pack(field);
    }
}
Also used : AnyValue(org.neo4j.values.AnyValue)

Example 18 with AnyValue

use of org.neo4j.values.AnyValue in project neo4j by neo4j.

the class CypherBoolean method in.

@CalledFromGeneratedCode
public static Value in(AnyValue lhs, AnyValue rhs) {
    assert rhs != NO_VALUE;
    ListValue anyValues = CypherFunctions.asList(rhs);
    boolean seenUndefined = false;
    for (AnyValue value : anyValues) {
        switch(lhs.ternaryEquals(value)) {
            case TRUE:
                return Values.TRUE;
            case UNDEFINED:
                seenUndefined = true;
            case FALSE:
                break;
            default:
                throw new IllegalStateException("Unknown state");
        }
    }
    return seenUndefined ? NO_VALUE : Values.FALSE;
}
Also used : ListValue(org.neo4j.values.virtual.ListValue) AnyValue(org.neo4j.values.AnyValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Example 19 with AnyValue

use of org.neo4j.values.AnyValue in project neo4j by neo4j.

the class PathValueBuilder method addMultipleIncoming.

/**
 * Adds multiple incoming relationships to the path
 *
 * @param relationships the incoming relationships to add
 * @param target the final target node of the path
 */
@CalledFromGeneratedCode
public void addMultipleIncoming(ListValue relationships, NodeValue target) {
    if (relationships.isEmpty()) {
        // nothing to do here
        return;
    }
    int i;
    for (i = 0; i < relationships.size() - 1; i++) {
        AnyValue value = relationships.value(i);
        if (notNoValue(value)) {
            RelationshipValue relationship = (RelationshipValue) value;
            nodes.add(relationship.startNode());
            rels.add(relationship);
        }
    }
    AnyValue last = relationships.value(i);
    if (notNoValue(last)) {
        rels.add((RelationshipValue) last);
        nodes.add(target);
    }
}
Also used : AnyValue(org.neo4j.values.AnyValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Example 20 with AnyValue

use of org.neo4j.values.AnyValue in project neo4j by neo4j.

the class PathValueBuilder method addMultipleOutgoing.

/**
 * Adds multiple outgoing relationships to the path
 *
 * @param relationships the outgoing relationships to add
 */
@CalledFromGeneratedCode
public void addMultipleOutgoing(ListValue relationships) {
    for (AnyValue value : relationships) {
        if (notNoValue(value)) {
            // we know these relationships have already loaded start and end relationship
            // so we should not use CypherFunctions::[start,end]Node to look them up
            RelationshipValue relationship = (RelationshipValue) value;
            nodes.add(relationship.endNode());
            rels.add(relationship);
        }
    }
}
Also used : AnyValue(org.neo4j.values.AnyValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Aggregations

AnyValue (org.neo4j.values.AnyValue)95 Test (org.junit.jupiter.api.Test)58 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)19 ListValue (org.neo4j.values.virtual.ListValue)14 CallableUserFunction (org.neo4j.kernel.api.procedure.CallableUserFunction)11 RelationshipValue (org.neo4j.values.virtual.RelationshipValue)11 CallableProcedure (org.neo4j.kernel.api.procedure.CallableProcedure)10 List (java.util.List)9 TextValue (org.neo4j.values.storable.TextValue)9 RawIterator (org.neo4j.collection.RawIterator)8 MapValue (org.neo4j.values.virtual.MapValue)8 Context (org.neo4j.kernel.api.procedure.Context)7 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)7 ArrayList (java.util.ArrayList)6 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)6 Values.stringValue (org.neo4j.values.storable.Values.stringValue)6 LocalDate (java.time.LocalDate)5 LocalTime (java.time.LocalTime)5 ZonedDateTime (java.time.ZonedDateTime)5 Arrays (java.util.Arrays)5