libfaster API Documentation  Development Version
Super fast distributted computing
workerFddGroup.h
1 #ifndef LIBFASTER_WORKERFDDGROUP_H
2 #define LIBFASTER_WORKERFDDGROUP_H
3 
4 #include <vector>
5 #include <unordered_map>
6 #include <string>
7 #include <memory>
8 
9 #include "workerFddBase.h"
10 
11 namespace faster{
12 
13  template <typename K>
14  class workerFddGroup : public workerFddBase{
15  private:
16  std::vector<workerFddBase*> members;
17  std::shared_ptr<std::vector<K>> uKeys;
18  std::shared_ptr<std::unordered_map<K, int>> keyMap;
19 
20  /*template <typename T0, typename T1, typename T2>
21  void decodeLast(void * func, fddOpType op, workerFddBase * dest, fastCommBuffer & buffer);
22  template <typename T0, typename T1>
23  inline void decodeThird(void * func, fddOpType op, workerFddBase * dest, fastCommBuffer & buffer);
24  template <typename T0>
25  inline void decodeSecond(void * func, fddOpType op, workerFddBase * dest, fastCommBuffer & buffer);// */
26 
27  std::vector< std::vector<void*>> findKeyInterval(size_t i);
28  std::vector< std::vector<void*> > * getMemberKeyLocations(size_t i);
29 
30 
31  //template <typename U, typename T0, typename T1, typename T2>
32  template <typename U>
33  void _apply(void * func, fddOpType op, workerFddBase * dest);
34  //template <typename L, typename U, typename T0, typename T1, typename T2>
35  template <typename L, typename U>
36  void _applyI(void * func, fddOpType op, workerFddBase * dest);
37 
38  //template <typename T0, typename T1, typename T2>
39  void _applyReduce(void * func, fddOpType op, fastCommBuffer & buffer);
40 
41  //template <typename T0, typename T1, typename T2>
42  void _preApply(void * func, fddOpType op, workerFddBase * dest);
43  //template <typename L, typename T0, typename T1, typename T2>
44  template <typename L>
45  void _preApplyI(void * func, fddOpType op, workerFddBase * dest);
46 
47 
48  //template <typename U, typename T0, typename T1, typename T2>
49  template <typename U>
50  void mapByKey(workerFddBase * dest, void * mapByKeyFunc);
51  //template <typename L, typename U, typename T0, typename T1, typename T2>
52  template <typename L, typename U>
53  void mapByKeyI(workerFddBase * dest, void * mapByKeyFunc);
54 
55  //template <typename U, typename T0, typename T1, typename T2>
56  template <typename U>
57  void flatMapByKey(workerFddBase * dest, void * mapByKeyFunc);
58  //template <typename L, typename U, typename T0, typename T1, typename T2>
59  template <typename L, typename U>
60  void flatMapByKeyI(workerFddBase * dest, void * mapByKeyFunc);
61 
62  template <typename U>
63  void bulkFlatMap(workerFddBase * dest, void * mapByKeyFunc);
64  template <typename L, typename U>
65  void bulkFlatMapI(workerFddBase * dest, void * mapByKeyFunc);
66 
67  void updateByKey(void * mapByKeyFunc);
68  void bulkUpdate(void * mapByKeyFunc);
69 
70  void exchangeDataByKey(fastComm *comm UNUSED){};
71  std::vector< std::vector<void*> > * getKeyLocations(){ return NULL; }
72 
73  void cogroup(fastComm *comm);
74 
75  public:
76  workerFddGroup(unsigned long int id, fddType keyT, std::vector<workerFddBase*> & members);
77 
78  fddType getType() { return Null; }
79  fddType getKeyType() { return this->keyType; }
80 
81  void setData( void * d UNUSED, size_t s UNUSED) {}
82  void setData( void * d UNUSED, size_t * ds UNUSED, size_t s UNUSED) {}
83  void setData( void * k UNUSED, void * d UNUSED, size_t s UNUSED) {}
84  void setData( void * k UNUSED, void * d UNUSED, size_t * ds UNUSED, size_t s UNUSED) {}
85 
86  void setDataRaw( void * d UNUSED, size_t s UNUSED) {}
87  void setDataRaw( void * d UNUSED, size_t * ds UNUSED, size_t s UNUSED) {}
88  void setDataRaw( void * k UNUSED, void * d UNUSED, size_t s UNUSED) {}
89  void setDataRaw( void * k UNUSED, void * d UNUSED, size_t * ds UNUSED, size_t s UNUSED) {}
90 
91  void * getItem(size_t UNUSED p) { return NULL; }
92 
93  void * getKeys() { return NULL; }
94  void * getData() { return NULL; }
95  size_t getSize() { return 0; }
96  size_t * getLineSizes() { return NULL; }
97  void setSize(size_t s UNUSED) {}
98 
99  size_t itemSize() { return 0; }
100  size_t baseSize() { return 0; }
101 
102  void deleteItem(void * item UNUSED) {}
103 
104  void shrink(){}
105  void insertl(void * v UNUSED) {}
106  void insert(void * k UNUSED, void * v UNUSED, size_t s UNUSED) {}
107 
108  void apply(void * func, fddOpType op, workerFddBase * dest, fastCommBuffer & buffer);
109  void preapply(unsigned long int id, void * func, fddOpType op, workerFddBase * dest, fastComm * comm) ;
110 
111  void collect(fastComm * comm UNUSED) { /* TODO */ }
112 
113  void * getUKeys(){ return &uKeys; }
114  void setUKeys(void * uk){ uKeys = * (std::shared_ptr<std::vector<K>>*) uk; }
115  void * getKeyMap(){ return &keyMap; }
116  void setKeyMap(void * km){ keyMap = * (std::shared_ptr<std::unordered_map<K, int>>*) km; }
117 
118  void writeToFile(void * path UNUSED, size_t procId UNUSED, void * sufix UNUSED){}
119  };
120 
121 }
122 #endif
unsigned int fddOpType
Dataset operation type.
Definition: definitions.h:41
libfaster main namespace
Definition: _workerFdd.h:11
unsigned int fddType
Dataset type.
Definition: definitions.h:16