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
}
faster::fastContext::startWorkers
void startWorkers()
Start worker machines computation.
Definition:
fastContext.cpp:58
std
STL namespace.
faster::fastContext::registerFunction
void registerFunction(void *funcP)
Register a user custom function in the context.
Definition:
fastContext.cpp:48
faster::fastContext::isDriver
bool isDriver()
Checks for the driver process.
Definition:
fastContext.cpp:76
faster::fastContext
Framework context class.
Definition:
fastContext.h:66
faster::fdd
Fast Distributted Dataset(FDD) is like a cluster distributted Array. This class is the user side impl...
Definition:
fastContext.h:24
faster
libfaster main namespace
Definition:
_workerFdd.h:11
faster.git
src
examples
fexample-int.cpp
Generated on Tue Nov 22 2016 19:01:07 for libfaster API Documentation by
1.8.12