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

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

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

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.jena.sparql.engine.binding.Binding;
import org.apache.jena.sparql.function.FunctionEnv;

/**
 * Aggregator for predefined keys
 *
 * @author raven
 *
 * @param 
 */
public class AccObject
    implements Acc>
{
    private Map> keyToSubAcc;

    public AccObject(Map> keyToSubAcc) {
        this.keyToSubAcc = keyToSubAcc;
    }

    @Override
    public void accumulate(Binding binding, FunctionEnv env) {
        for(Entry> entry : keyToSubAcc.entrySet()) {
            Acc acc = entry.getValue();
            acc.accumulate(binding, env);
        }
    }

    @Override
    public Map getValue() {
        Map result = new HashMap();

        for(Entry> entry : keyToSubAcc.entrySet()) {
            K k = entry.getKey();
            Acc acc = entry.getValue();
            Object v = acc.getValue();
            result.put(k, v);
        }

        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy