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

org.heigit.bigspatialdata.oshdb.api.mapreducer.MutableWeightedDouble Maven / Gradle / Ivy

Go to download

API to query the OpenStreetMap History Database. Includes MapReduce functionality to filter, analyze and aggregate data.

There is a newer version: 1.2.3
Show newest version
package org.heigit.bigspatialdata.oshdb.api.mapreducer;

import java.io.Serializable;
import org.heigit.bigspatialdata.oshdb.api.generic.WeightedValue;

/**
 * Mutable version of WeightedValue type.
 *
 * 

For internal use to do faster aggregation during reduce operations.

*/ class MutableWeightedDouble implements Serializable { double num; double weight; private MutableWeightedDouble(double num, double weight) { this.num = num; this.weight = weight; } static MutableWeightedDouble identitySupplier() { return new MutableWeightedDouble(0.0, 0.0); } static MutableWeightedDouble accumulator( MutableWeightedDouble acc, WeightedValue cur) { acc.num = acc.num + cur.getValue().doubleValue() * cur.getWeight(); acc.weight += cur.getWeight(); return acc; } static MutableWeightedDouble combiner( MutableWeightedDouble a, MutableWeightedDouble b) { return new MutableWeightedDouble(a.num + b.num, a.weight + b.weight); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy