Skip to content
Yuzhen Huang edited this page Apr 24, 2019 · 3 revisions

API

The complete Tangram library API can be found in core/plan/context.hpp.

  template<typename C, typename... ArgT>
  static C* collection(ArgT... args);

  template<typename D>
  static auto* distribute(std::vector<D> data, int num_parts = 1, std::string name = "");

  // distribute a std::vector by key.
  // The user-defined type should have Key() function and is serializable.
  // Users should make sure there is only one key per object.
  template<typename D>
  static auto* distribute_by_key(std::vector<D> data, int num_parts = 1, std::string name = "");

  template<typename C, typename F>
  static void foreach(C* c, F f, std::string name = "");

  template<typename Parse>
  static auto* load(std::string url, Parse parse, int max_line_per_part = -1, std::string name = "");

  template<typename Parse>
  static auto* load_wholefiles(std::string url, Parse parse, int max_line_per_part = -1, std::string name = "");

  /*
   * return a collection that need to be accessed in special way, see wordcount.cpp
   */
  static auto* load_block_meta(std::string url, std::string name = "");

  static auto* load_wholefiles_meta(std::string url, std::string name = "");

  template<typename C, typename F>
  static void write(C* c, std::string url, F write, std::string name = "");

  template<typename C>
  static void checkpoint(C* c, std::string url, std::string name = "");

  template<typename C>
  static void loadcheckpoint(C* c, std::string url, std::string name = "");

  template<typename D>
  static auto* placeholder(int num_parts = 1, std::string name = "");

  // user can specify KeyToPartT for the placeholder
  template<typename D, typename KeyToPartT>
  static auto* placeholder(int num_parts = 1, std::string name = "");

  // user can specify KeyToPartT for the placeholder
  template<typename D, typename KeyToPartT>
  static auto* placeholder(int num_parts, std::shared_ptr<KeyToPartT> key_to_part_mapper, std::string name = "");

  // range placeholder
  template<typename D, typename KeyToPartT>
  static auto* range_placeholder(std::shared_ptr<KeyToPartT> key_to_part_mapper, std::string name = "");
  template<typename D>
  static auto* placeholder(std::vector<third_party::Range> ranges, std::string name = "");

  template<typename C1, typename C2, typename M, typename J>
  static auto* mapupdate(C1* c1, C2* c2, M m, J j);

  template<typename C1, typename C2, typename M, typename J>
  static auto* mappartupdate(C1* c1, C2* c2, M m, J j);

  template<typename C1>
  static void count(C1* c1, std::string name = "");

  template<typename C1, typename C2, typename C3, typename M, typename J>
  static auto* mappartwithupdate(C1* c1, C2* c2, C3* c3, M m, J j);

  // sort each partition in a collection.
  // this can be used in pagerank which requires each vextex and links
  // objects correspond to each other.
  template<typename C>
  static void sort_each_partition(C* c,
    typename std::enable_if_t<std::is_base_of<Indexable<typename C::ObjT>, typename C::PartT>::value >* = 0);
Clone this wiki locally