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

org.aksw.jenax.arq.aggregation.AccComputeBinding Maven / Gradle / Ivy

The newest version!
package org.aksw.jenax.arq.aggregation;

import java.util.Map;
import java.util.function.Function;

import org.aksw.commons.collector.domain.Accumulator;
import org.apache.jena.graph.Node;
import org.apache.jena.sparql.core.Var;
import org.apache.jena.sparql.engine.binding.Binding;
import org.apache.jena.sparql.engine.binding.BindingBuilder;

public class AccComputeBinding
    implements Accumulator
{
    //protected org.apache.jena.sparql.expr.aggregate.Accumulator delegate;
    protected Map> varToNodeFn;
    protected Accumulator delegate;

    public AccComputeBinding(Map> varToNodeFn, Accumulator delegate) {
        super();
        this.varToNodeFn = varToNodeFn;
        this.delegate = delegate;
    }

    @Override
    public void accumulate(B input, E env) {
        BindingBuilder builder = BindingBuilder.create();

        varToNodeFn.forEach((key, value) -> {
            Node node = value.apply(input);
            builder.add(key, node);
        });

        delegate.accumulate(builder.build(), env);
    }

    @Override
    public T getValue() {
        T result = delegate.getValue();
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy