// Reads TSV line by line and extracts fields Rows SheetReader::ParseTSV(std::string fname) { Rows rows; std::ifstream file(fname); std::string line; std::string tab = "\t"; while (std::getline(file, line)) { rows.push_back(Rows::value_type()); int tab_pos = -1; int last_tab_pos = -1; do { last_tab_pos = tab_pos + 1; tab_pos = line.find(tab, tab_pos + 1); std::size_t start = last_tab_pos; std::size_t count = tab_pos - last_tab_pos; std::string field = line.substr(start, count); rows.back().push_back(field); } while (tab_pos != std::string::npos); } return std::move(rows); }
void DLargestCommonSubSequence::distributedInit() { // allocate storage for rows before int rowsToExportPerProc = (0 == chunkStride_%n_) ? chunkStride_/n_ : chunkStride_/n_+1; //std::cout << "rowsToExportPerProc " // << rowsToExportPerProc << std::endl; for(int i = 0; i < rowsToExportPerProc; ++i) { Row curr; curr.resize(chunkLength_); over_.push_back(curr); bsp_push_reg(over_.back().data(), sizeof(int)*chunkLength_); //std::cout << "Proc " << id_ << // " Last Row index " << i << " addr: "; // std::cout << over_.back().data() // << std::endl << std::flush; } for(int i = 0; i < chunkStride_; ++i) { for(int j = 0; j < chunkStride_; ++j) { if(id_ != i % n_) continue; // allocate L L_[getCPair(i,j)] = new int*[chunkLength_]; for(int k = 0; k < chunkLength_; ++k) { L_[getCPair(i,j)][k] = new int [chunkLength_]; memset(L_[getCPair(i,j)][k], 0, chunkLength_*sizeof(int)); } //allocate chunks for lastRow if(i > 0) { L_[getCPair(i-1,j)] = new int*[chunkLength_]; for(int k = 0; k < chunkLength_; ++k) { if(k < chunkLength_-1) { L_[getCPair(i-1,j)][k] = NULL; } else { L_[getCPair(i-1,j)][k] = new int[chunkLength_]; memset(L_[getCPair(i-1,j)][k], 0, chunkLength_*sizeof(int)); } } } } } }
int main() { std::vector<std::string> words = { "Hello", "from", "GCC", __VERSION__, "!" }; Row row; //row["value"] = std::string("Hello"); row["value"] = boost::optional<std::string>("Hello"); Rows rows; rows.push_back(row); //std::cout << "row[\"value\"] " << boost::any_cast<std::string>( row["value"] ) << "\n"; //std::cout << "rows[0][\"value\"] " << boost::any_cast<std::string>( rows[0]["value"] ) << "\n"; //std::cout << "row[\"value\"] " << row["value"] << "\n"; //std::cout << "rows[0][\"value\"] " << rows[0]["value"] << "\n"; boost::optional<std::string> blah = rows[0]["value"]; std::cout << words << std::endl; }