本文整理汇总了C++中Collector::collect方法的典型用法代码示例。如果您正苦于以下问题:C++ Collector::collect方法的具体用法?C++ Collector::collect怎么用?C++ Collector::collect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collector
的用法示例。
在下文中一共展示了Collector::collect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reduce
bool PageRankReducer::reduce(const void* key, KeyValueIterator& values, Collector& collector) const
{
//<url, pagerank, linkoutlist> as reducer intput
//<url, newpagerank, linkoutlist> as reducer output
//the formula of pagerank:
//pr(a) - (1-d) = d * (pr(b)/l(b) + pr(c)/l(c) + ...)
//d is the damping factor
PageRankValue value;
int count = 0;
const double damping = 0.85;
while(values.hasMore()){
PageRankValue* pValue = (PageRankValue*)(values.next());
value.pagerank += damping * pValue->pagerank;
if(pValue->linkoutURLs.size() > 0){
for(int i = 0; i < pValue->linkoutURLs.size(); i ++){
value.linkoutURLs.push_back(pValue->linkoutURLs[i]);
}
}
count ++;
}
collector.collect(key, &value);
return true;
}
示例2: map
bool WordFrequencyMapper::map(const void* key, const void* value, Collector& collector) const
{
//<char*, char*> as mapper intput
//<char*, int> as mapper output
int outValue = 1;
int outputCnt = 0;
int bodyLen = strlen(*(char**)value);
//do parsing
m_parser->init_page(*(char**)value);
m_parser->convert_charset("skip");
m_parser->delete_tags();
m_parser->cut_words(1);
m_parser->end_page();
//processing with the keywords list
char *p = m_parser->get_keywords();
//cout << p << endl;
p=strtok(p," ");
while(p){
switch(*p){
case DELI_WEIGHT:
case DELI_LOC:
case DELI_PARA:
//skip these tokens
break;
case '\0':
cout << "+";
default:{
char** pData = &p;
collector.collect( pData, &outValue);
outputCnt ++;
}
}
p=strtok(NULL," ");
}
//cout << *(char**)key << " : " << bodyLen << " : " << outputCnt << endl;
return true;
}
示例3: startApp
extern "C" int startApp(thread_arg_t* arg) {
int argc = arg->argc;
char** argv = arg->argv;
create_vm_t func = arg->func;
free(arg);
#ifndef MULTIPLE_GC
Collector::inject_my_thread(&argc);
VirtualMachine* VM = func();
VM->runApplication(argc, argv);
Collector::remove_my_thread();
Collector::collect();
#else
Collector* GC = Collector::allocate();
GC->inject_my_thread(&argc);
func(argc, argv);
GC->remove_my_thread();
GC->collect();
#endif
return 0;
}