コード例 #1
0
ファイル: HBaseDeamon.cpp プロジェクト: korechika/Deamon
// static void 
std::string
getRowFunc(std::string table, char rowbuf[ROW_SIZE], std::vector<TRowResult> rowResult, HbaseClient client, HPacket *hpacket)
{
	std::string row(rowbuf);
	const std::map<Text, Text>  dummyAttributes; // see HBASE-6806 HBASE-4658
	client.getRow(rowResult, table, row, dummyAttributes);
	return returnValue(rowResult, hpacket);
}
コード例 #2
0
ファイル: testclient.cpp プロジェクト: knotman90/HPRS
auto createFrameHBase(const std::string& rowkey, const std::string& table,  HbaseClient& client) {
    std::vector<TRowResult> res;
    std::map<Text, Text>  attributes;
    client.getRow(res, table, rowkey,attributes);

    boost::shared_ptr<Frame<T>> frame(new Frame<T>()) ;

    //binary converter
    converter<int64_t> c_int64;
    converter<double> c_double;

    for(int i=0; i<res.size(); i++) {
        //foreach particle get its coordinates
        TRowResult a = res[i];
        for(auto it = a.columns.begin(); it != a.columns.end() ; ++it ) {
            std::string key = it->first;

            if(key.find("M:c") != std::string::npos) { //coordinate info for the particle
                //get the particle ID
                Particle<T>* p = new Particle<T>();

                std::string key_suffix = key.substr(10,8); //binario long long
                int64_t p_id =  c_int64.fromBytes(reinterpret_cast<const unsigned char*>(key_suffix.c_str()),true);
                p->id = p_id;

                //read coordinate ffor particle p_id
                std::string value= a.columns.at(key).value; //24 bytes: 3 double




                //firstr coordinate
                std::string value_suffix = value.substr(0,8);
                double res_value =  c_double.fromBytes(reinterpret_cast<const unsigned char*>(value_suffix.c_str()),true);
                p->p.x = res_value;

                //second coordinate
                value_suffix = value.substr(8,8);
                res_value =  c_double.fromBytes(reinterpret_cast<const unsigned char*>(value_suffix.c_str()),true);
                p->p.y = res_value;

                //third coordinate
                value_suffix = value.substr(16,8);
                res_value =  c_double.fromBytes(reinterpret_cast<const unsigned char*>(value_suffix.c_str()),true);
                p->p.z = res_value;

                frame->particles.push_back(*p);
                printf("Coordinate for particle %i are [%.2f,%.2f,%.2f]\n",p->id,p->p.x,p->id,p->p.y,p->id,p->p.z);

            }
        }

    }
    return frame;
}