Ejemplo n.º 1
0
// MAPPED
//
void Section::setValue(const char *name, const char *value)
{
	if(name)
	{
		std::string myname=name;
		KeyValue *mydata = d_kv_map[myname];
		if(mydata)
		{
			mydata->setValue(value);
			mydata->isDeleted(false);
			
		} 
		else
		{	
			KeyValue *newdata = new KeyValue();
			newdata->setName(name);
			newdata->setValue(value);
			d_allDataVector.push_back(newdata);
			d_kv_vector.push_back(newdata);
			d_kv_map[myname] = newdata;
		}
	}
}
Ejemplo n.º 2
0
shared_ptr<KeyValue> WordFrequencyFeeder::next()
{
    KeyValueField key;
    KeyValueField value;
    
    try{
        const TWReader::T_PageRecord* record =  m_reader->nextRecord();
        
        if(record){
            key.appendStr(record->url);
            value.appendStr(record->body);

            KeyValue* nextKeyValue = new KeyValue(1);
            nextKeyValue->setKey(key);
            nextKeyValue->setValue(0,value);
            shared_ptr<KeyValue> pNextKeyValue(nextKeyValue);
            return pNextKeyValue;
        }

    }catch (TWReaderException &E) {
        cout << E.what() << endl;
    } catch (exception &E) {
        cout << E.what() << endl;
    }
    
    //return a nul object, it sucks.
//    key.appendStr("");
//    value.appendStr("");
//    KeyValue* nextKeyValue = new KeyValue(1);
//    nextKeyValue->setKey(key);
//    nextKeyValue->setValue(0,value);
//    shared_ptr<KeyValue> pNextKeyValue(nextKeyValue);
    KeyValue* nextKeyValue = NULL;
    shared_ptr<KeyValue> pNextKeyValue(nextKeyValue);
    return pNextKeyValue;
}