当前位置: 首页>>代码示例>>C++>>正文


C++ Collector::collect方法代码示例

本文整理汇总了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;
}
开发者ID:kyhhdm,项目名称:TPlatform,代码行数:27,代码来源:PageRankReducer.cpp

示例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;
}
开发者ID:kyhhdm,项目名称:TPlatform,代码行数:44,代码来源:WordFrequencyMapper.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:20,代码来源:


注:本文中的Collector::collect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。