6 #include "_workerIFdd.h" 7 #include "indexedFddStorageExtern.cpp" 9 using std::chrono::system_clock;
10 using std::chrono::duration_cast;
11 using std::chrono::milliseconds;
14 template <
typename K,
typename T>
15 template <
typename L,
typename U>
17 T * d = this->localData->getData();
18 size_t s = this->localData->getSize();
19 K * ik = (K*) this->localData->getKeys();
20 L * ok = (L*) dest->getKeys();
21 U * od = (U*) dest->getData();
26 #pragma omp parallel for 27 for (
size_t i = 0; i < s; ++i){
28 std::pair<L,U> r = mapFunc(ik[i], d[i]);
58 template <
typename K,
typename T>
59 template <
typename U>
61 T * d = this->localData->getData();
62 size_t s = this->localData->getSize();
63 K * ik = (K*) this->localData->getKeys();
64 U * od = (U*) dest->getData();
68 #pragma omp parallel for 69 for (
size_t i = 0; i < s; ++i){
70 od[i] = mapFunc(ik[i], d[i]);
97 template <
typename K,
typename T>
98 template <
typename L,
typename U>
102 K * ik = (K*) this->localData->getKeys();
103 T *
id = this->localData->getData();
104 size_t s = this->localData->getSize();
110 auto kL = this->findKeyInterval(ik,
id, s);
117 dest->setSize(this->uKeys->size());
118 L * ok = (L*) dest->getKeys();
119 U * od = (U*) dest->getData();
127 #pragma omp parallel for 128 for (
size_t i = 0; i < this->uKeys->size(); i++){
129 std::pair<L,U> r = mapByKeyFunc((*this->uKeys)[i], kL[i]);
174 template <
typename K,
typename T>
175 template <
typename U>
178 T * d = this->localData->getData();
179 size_t s = this->localData->getSize();
180 K * ik = (K*) this->localData->getKeys();
182 auto keyLocations = this->findKeyInterval(ik, d, s);
184 dest->setSize(keyLocations.size());
185 U * od = (U*) dest->getData();
188 #pragma omp parallel for 189 for (
size_t i = 0; i < this->uKeys->size(); ++i){
192 K & key = (*this->uKeys)[i];
193 auto loc = keyLocations[i];
195 od[i] = mapByKeyFunc(key, loc);
237 template <
typename K,
typename T>
238 template <
typename L,
typename U>
240 bulkMapFunc((L*) (dest->getKeys()), (U *) dest->getData(), (K*) this->localData->getKeys(), (T *)this->localData->getData(), this->localData->getSize());
247 template <typename K, typename T>
248 template <typename U>
249 void faster::_workerIFdd<K,T>::bulkMap (workerFddBase * dest, bulkMapIFunctionP<K,T,U> bulkMapFunc){
250 bulkMapFunc((U*) dest->getData(), (K*) this->localData->getKeys(), (T *)this->localData->getData(), this->localData->getSize());
261 template <
typename K,
typename T>
262 template <
typename L,
typename U>
264 T * d = this->localData->getData();
265 size_t s = this->localData->getSize();
266 K * ik = (K*) this->localData->getKeys();
267 std::deque<std::pair<L,U>> resultList;
271 std::deque<std::pair<L,U>> partResultList;
274 for (
size_t i = 0; i < s; ++i){
275 std::deque<std::pair<L,U>> r = flatMapFunc(ik[i], d[i]);
277 partResultList.insert(partResultList.end(), r.begin(), r.end());
281 resultList.insert(resultList.end(), partResultList.begin(), partResultList.end() );
284 dest->insertl(&resultList);
311 template <
typename K,
typename T>
312 template <
typename U>
314 T * d = this->localData->getData();
315 size_t s = this->localData->getSize();
316 K * ik = (K*) this->localData->getKeys();
317 std::deque<U> resultList;
321 std::deque<U> partResultList;
324 for (
size_t i = 0; i < s; ++i){
325 std::deque<U> r = flatMapFunc(ik[i], d[i]);
327 partResultList.insert(partResultList.end(), r.begin(), r.end());
331 resultList.insert(resultList.end(), partResultList.begin(), partResultList.end() );
334 dest->insertl(&resultList);
361 template <
typename K,
typename T>
362 template <
typename L,
typename U>
368 bulkFlatMapFunc(ok, result, rSize, this->localData->getKeys(), this->localData->getData(), this->localData->getSize());
369 dest->setData(ok, result, rSize);
384 template <
typename K,
typename T>
385 template <
typename U>
390 bulkFlatMapFunc(result, rSize, this->localData->getKeys(), this->localData->getData(), this->localData->getSize());
391 dest->setData(result, rSize);
408 template <
class K,
class T>
409 template <
typename L,
typename U>
413 map<L,U>(dest, (ImapIFunctionP<K,T,L,U>) func);
417 mapByKey<L,U>(dest, (ImapByKeyIFunctionP<K,T,L,U>) func);
421 bulkMap<L,U>(dest, ( IbulkMapIFunctionP<K,T,L,U> ) func);
425 flatMap<L,U>(dest, ( IflatMapIFunctionP<K,T,L,U> ) func);
429 bulkFlatMap<L,U>(dest, ( IbulkFlatMapIFunctionP<K,T,L,U> ) func);
464 template <
class K,
class T>
465 template <
typename U>
469 map<U>(dest, (mapIFunctionP<K,T,U>) func);
473 mapByKey<U>(dest, (mapByKeyIFunctionP<K,T,U>) func);
477 bulkMap<U>(dest, ( bulkMapIFunctionP<K,T,U> ) func);
481 flatMap<U>(dest, ( flatMapIFunctionP<K,T,U> ) func);
485 bulkFlatMap<U>(dest, ( bulkFlatMapIFunctionP<K,T,U> ) func);
520 template <
class K,
class T>
521 template <
typename L>
523 switch (dest->getType()){
525 case Char: _applyI<L,char> (func, op, dest);
break;
526 case Int: _applyI<L,int> (func, op, dest);
break;
527 case LongInt: _applyI<L,long int>(func, op, dest);
break;
528 case Float: _applyI<L,float> (func, op, dest);
break;
529 case Double: _applyI<L,double> (func, op, dest);
break;
535 case String: _applyI<L,std::string>(func, op, dest);
break;
537 case CharV: _applyI<L,std::vector<char>> (func, op, dest);
break;
538 case IntV: _applyI<L,std::vector<int>> (func, op, dest);
break;
539 case LongIntV: _applyI<L,std::vector<long int>>(func, op, dest);
break;
540 case FloatV: _applyI<L,std::vector<float>> (func, op, dest);
break;
541 case DoubleV: _applyI<L,std::vector<double>> (func, op, dest);
break;
546 template <
class K,
class T>
548 switch (dest->getType()){
550 case Char: _apply<char> (func, op, dest);
break;
551 case Int: _apply<int> (func, op, dest);
break;
552 case LongInt: _apply<long int> (func, op, dest);
break;
553 case Float: _apply<float> (func, op, dest);
break;
554 case Double: _apply<double> (func, op, dest);
break;
560 case String: _apply<std::string>(func, op, dest);
break;
562 case CharV: _apply<std::vector<char>> (func, op, dest);
break;
563 case IntV: _apply<std::vector<int>> (func, op, dest);
break;
564 case LongIntV:_apply<std::vector<long int>>(func, op, dest);
break;
565 case FloatV: _apply<std::vector<float>> (func, op, dest);
break;
566 case DoubleV: _apply<std::vector<double>> (func, op, dest);
break;
570 template <
typename K,
typename T>
572 switch (dest->getKeyType()){
573 case Null: _preApply(func, op, dest);
break;
574 case Char: _preApplyI<char>(func, op, dest);
break;
575 case Int: _preApplyI<int>(func, op, dest);
break;
576 case LongInt: _preApplyI<long int>(func, op, dest);
break;
577 case Float: _preApplyI<float>(func, op, dest);
break;
578 case Double: _preApplyI<double>(func, op, dest);
break;
579 case String: _preApplyI<std::string>(func, op, dest);
break;