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

org.heigit.ohsome.oshdb.api.mapreducer.Mappable Maven / Gradle / Ivy

Go to download

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

The newest version!
package org.heigit.ohsome.oshdb.api.mapreducer;

import org.heigit.ohsome.oshdb.util.function.SerializableFunction;
import org.heigit.ohsome.oshdb.util.function.SerializablePredicate;
import org.jetbrains.annotations.Contract;

/**
 * Interface for common "monadic" methods in {@link MapReducer} and {@link MapAggregator}.
 *
 * @param  the (arbitrary) data type which is used as the input of the interface's methods.
 */
public interface Mappable {
  /**
   * Set an arbitrary `map` transformation function.
   *
   * @param mapper function that will be applied to each data entry (osm entity
   *        snapshot or contribution)
   * @param  an arbitrary data type which is the return type of the
   *        transformation `map` function
   * @return a modified copy of the current "Mappable" object operating on the
   *         transformed type (<R>)
   */
  @Contract(pure = true)
   Mappable map(SerializableFunction mapper);

  /**
   * Set an arbitrary `flatMap` transformation function, which returns list with
   * an arbitrary number of results per input data entry. The results of this
   * function will be "flattened", meaning that they can be for example
   * transformed again by setting additional `map` functions.
   *
   * @param flatMapper function that will be applied to each data entry (osm
   *        entity snapshot or contribution) and returns a list of results
   * @param  an arbitrary data type which is the return type of the
   *        transformation `map` function
   * @return a modified copy of the current "Mappable" object operating on the
   *         transformed type (<R>)
   */
  @Contract(pure = true)
   Mappable flatMap(SerializableFunction> flatMapper);

  /**
   * Adds a custom arbitrary filter that gets executed in the current
   * transformation chain.
   *
   * @param f the filter function that determines if the respective data should
   *        be passed on (when f returns true) or discarded (when f returns false)
   * @return a modified copy of this "Mappable" (can be used to chain multiple
   *         commands together)
   */
  @Contract(pure = true)
  Mappable filter(SerializablePredicate f);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy