libfaster API Documentation  Development Version
Super fast distributted computing
fexample-int.cpp
1 #include <iostream>
2 #include "libfaster.h"
3 
4 #define NUMITEMS 10*1000
5 
6 using namespace std;
7 using namespace faster;
8 
9 int map1(int & input){
10  //cerr << input << " ";
11  return input / 2;
12 }
13 
14 int reduce1(int &a, int &b){
15  //cerr << a+b << " ";
16  return a + b;
17 }
18 
19 
20 int main(int argc, char ** argv){
21  // Init Faster Framework
22  cout << "Init FastLib" << '\n';
23  fastContext fc(argc,argv);
24 
25  fc.registerFunction((void*) &map1);
26  fc.registerFunction((void*) &reduce1);
27 
28  fc.startWorkers();
29  if (!fc.isDriver())
30  return 0;
31 
32  cout << "Generate Data" << '\n';
33  int rawdata[NUMITEMS];
34 
35  for ( int i = 0; i < NUMITEMS; ++i )
36  rawdata[i] = 2;
37 
38  cout << "Import Data" << '\n';
39  fdd <int> data(fc, rawdata, NUMITEMS);
40 
41  cout << "Process Data" << '\n';
42  int result = data.map<int>(&map1)->reduce(&reduce1);
43 
44  cout << "DONE!" << '\n';
45 
46  std::cout << "Resut:" << result << "\n";
47 
48  return 0;
49 }
void startWorkers()
Start worker machines computation.
Definition: fastContext.cpp:58
STL namespace.
void registerFunction(void *funcP)
Register a user custom function in the context.
Definition: fastContext.cpp:48
bool isDriver()
Checks for the driver process.
Definition: fastContext.cpp:76
Framework context class.
Definition: fastContext.h:66
Fast Distributted Dataset(FDD) is like a cluster distributted Array. This class is the user side impl...
Definition: fastContext.h:24
libfaster main namespace
Definition: _workerFdd.h:11