All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.cypher.executionPlan.WhereExecutionStep Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.cypher.executionPlan;

import org.vertexium.cypher.VertexiumCypherQueryContext;
import org.vertexium.cypher.VertexiumCypherResult;

public class WhereExecutionStep extends ExecutionStepWithChildren {
    private final String whereStepResultName;

    public WhereExecutionStep(ExecutionStepWithResultName whereStep) {
        super(whereStep);
        this.whereStepResultName = whereStep.getResultName();
    }

    @Override
    public VertexiumCypherResult execute(VertexiumCypherQueryContext ctx, VertexiumCypherResult source) {
        source = super.execute(ctx, source);

        return source.filter(row -> {
            Object value = row.get(whereStepResultName);
            row.popScope();
            if (value == null) {
                return false;
            } else if (value instanceof Boolean) {
                return (Boolean) value;
            } else {
                return value != null;
            }
        });
    }

    @Override
    public String toString() {
        return String.format("%s {whereStepResultName:'%s'}", super.toString(), whereStepResultName);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy