22 TwitterEdge(
short mycount,
bool myfollow, time_t mylatest):count(mycount), follower(myfollow), latest(mylatest) {};
25 bool TweetWithinInterval (time_t begin, time_t end)
const {
return ((count > 0) && (begin <= latest && latest <= end)); };
26 bool TweetSince (time_t begin)
const {
return ((count > 0) && (begin <= latest)); };
27 bool LastTweetBy (time_t end)
const {
return ((count > 0) && (latest <= end)); };
29 operator bool ()
const {
return true; } ;
33 std::cout <<
"Error: TwitterEdge::operator+=() shouldn't be executed" << std::endl;
35 follower |= rhs.follower;
37 latest = std::max(latest, rhs.latest);
42 return ((follower == b.follower) && (latest == b.latest) && (count == b.count));
53 template <
typename IT>
61 if( twe.follower == 0 && twe.latest == 0 && twe.count == 0)
85 return combblas::MPIType<TwitterEdge>();
90 TwitterInteraction twi;
91 size_t entryLength = fread (&twi,
sizeof(TwitterInteraction),1,rFile);
94 val =
TwitterEdge(twi.retweets, twi.follow, twi.twtime);
96 std::cout <<
"Not enough bytes read in binaryfill " << std::endl;
100 template <
typename c,
typename t>
114 int year, month, day, hour, min, sec;
115 sscanf (date.c_str(),
"%d-%d-%d",&year, &month, &day);
116 sscanf (time.c_str(),
"%d:%d:%d",&hour, &min, &sec);
118 memset(&timeinfo, 0,
sizeof(
struct tm));
119 timeinfo.tm_year = year - 1900;
120 timeinfo.tm_mon = month - 1 ;
121 timeinfo.tm_mday = day;
122 timeinfo.tm_hour = hour;
123 timeinfo.tm_min = min;
124 timeinfo.tm_sec = sec;
125 tw.latest = timegm(&timeinfo);
126 if(tw.latest == -1) { std::cout <<
"Can not parse time date" << std::endl; exit(-1);}
137 template <
typename c,
typename t>
140 os << row <<
"\t" << col <<
"\t";
141 os << tw.follower <<
"\t";
142 os << tw.count <<
"\t";
143 os << tw.latest << std::endl;
146 struct TwitterInteraction
164 return (
id == rhs.
id);
168 return (
id != rhs.
id);
172 std::cout <<
"Adding parent with id: " << rhs.
id <<
" to this one with id " <<
id << std::endl;
183 template <
typename IT>
189 os <<
"Parent=" << twe.
id;
198 template <
typename IT>
205 template <
typename SR,
typename T>
206 void select2nd(
void * invec,
void * inoutvec,
int * len, MPI_Datatype *datatype);
209 template <
typename SR,
typename VECTYPE>
210 static VECTYPE filtered_select2nd(
const TwitterEdge & arg1,
const VECTYPE & arg2, time_t & sincedate)
215 memset(&timeinfo, 0,
sizeof(
struct tm));
216 int year, month, day, hour, min, sec;
217 year = 2009; month = 7; day = 1;
218 hour = 0; min = 0; sec = 0;
220 timeinfo.tm_year = year - 1900;
221 timeinfo.tm_mon = month - 1 ;
222 timeinfo.tm_mday = day;
223 timeinfo.tm_hour = hour;
224 timeinfo.tm_min = min;
225 timeinfo.tm_sec = sec;
226 sincedate = timegm(&timeinfo);
228 std::ostringstream outs;
229 outs <<
"Initializing since date (only once) to " << sincedate << std::endl;
239 SR::returnedSAID(
true);
263 static bool flag =
false;
277 MPI_Op_create(select2nd<LatestRetwitterBFS,ParentType>,
false, &MPI_BFSADD);
283 return filtered_select2nd<LatestRetwitterBFS>(arg1, arg2, sincedate);
294 template <
typename SR,
typename T>
295 void select2nd(
void * invec,
void * inoutvec,
int * len, MPI_Datatype *datatype)
297 T * pinvec =
static_cast<T*
>(invec);
298 T * pinoutvec =
static_cast<T*
>(inoutvec);
299 for (
int i = 0; i < *len; i++)
301 pinoutvec[i] = SR::add(pinvec[i], pinoutvec[i]);
308 struct getfringe:
public std::binary_function<ParentType, ParentType, ParentType>
319 struct seldegree:
public std::binary_function<ParentType, int64_t, int64_t>
329 struct passifthere:
public std::binary_function<ParentType, int64_t, bool>
350 uint8_t operator() (
double t1,
double t2)
383 static double id() {
return 0.0; }
390 static bool flag =
false;
397 static double add(
const double & arg1,
const double & arg2)
399 return std::min(arg1, arg2);
409 return filtered_select2nd<LatestRetwitterMIS>(arg1, arg2, sincedate);
422 static double id() {
return 0.0; }
429 static bool flag =
false;
436 static double add(
const double & arg1,
const double & arg2)
443 MPI_Op_create(select2nd<LatestRetwitterSelect2nd,double>,
false, &MPI_SEL2NDADD);
444 return MPI_SEL2NDADD;
449 return filtered_select2nd<LatestRetwitterSelect2nd>(arg1, arg2, sincedate);
ParentType operator()(ParentType x, const ParentType &y) const
MPI_Datatype getMPIType()
bool operator()(ParentType x, const int64_t &y) const
bool operator()(ParentType x, const ParentType &y) const
bool operator()(const ParentType &x) const
void binaryfill(FILE *rFile, IT &row, IT &col, TwitterEdge &val)
void save(std::basic_ostream< c, t > &os, const TwitterEdge &tw, IT row, IT col)
static void Print(const std::string &s)
TwitterEdge getNoNum(IT row, IT col)
const ParentType operator++(int)
bool operator()(double m, double c) const
int64_t operator()(ParentType x, const int64_t &y) const
TwitterEdge read(std::basic_istream< c, t > &is, IT row, IT col)
SpDCCols< IT, NT > * multiply(SpDCCols< IT, NT > &splitA, SpDCCols< IT, NT > &splitB, CCGrid &CMG, bool isBT, bool threaded)
ParentType & operator+=(const ParentType &rhs)