Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 386692 Details for
Bug 525442
Internal compiler error: Error reporting routines re-entered.
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Truth.cpp
Truth.cpp (text/plain), 3.64 KB, created by
Petr Hudecek
on 2014-10-14 20:50:49 UTC
(
hide
)
Description:
Truth.cpp
Filename:
MIME Type:
Creator:
Petr Hudecek
Created:
2014-10-14 20:50:49 UTC
Size:
3.64 KB
patch
obsolete
>#include <cstdio> >#include <ctime> >#include <algorithm> >#include <iostream> >#include <fstream> >#include <string> >#include <vector> >#include <queue> >#include <cstdint> >#include <tuple> >#include <cinttypes> >#pragma warning (disable : 4997) >#define INPUTFILENAME "10GB.txt" >#define OUTPUTFILENAME "output.txt" >#define ENTRIES_IN_MEMORY 1000000 >using namespace std; > >struct entry { > uint64_t key; > uint64_t value; > entry() > { > } > entry(uint64_t key_, uint64_t value_) > { > key = key_; > value = value_; > } >}; > >bool operator <(const entry& x, const entry& y) >{ > if (x.key < y.key) > { > return true; > } > else if (x.key == y.key) > { > return x.value < y.value; > } > else > { > return false; > } > //return std::tie(x.key, x.value) < std::tie(y.key, y.value); >}; > > >clock_t beginning; >size_t chunkIndex = 0; >size_t fromLastChunkHowMuch = -1; >entry chunk[ENTRIES_IN_MEMORY]; >std::vector<ifstream> chunks; > >string timestring() >{ > return std::string(" (") + std::to_string((clock() - beginning) / CLOCKS_PER_SEC) + std::string(" s)"); >} > >void dumpChunk() >{ > // Sort > if (fromLastChunkHowMuch == -1) > { > std::sort(begin(chunk), end(chunk)); > } > else > { > std::sort(begin(chunk), begin(chunk) + fromLastChunkHowMuch); > } > > // Write > > FILE* pChunk; > std::string filename = (std::string("chunk") + std::to_string(chunkIndex)); > > > pChunk = fopen(filename.c_str(), "wb"); > /* > if (fromLastChunkHowMuch == -1) > { > fwrite(chunk, 1, ENTRIES_IN_MEMORY*sizeof(entry), pChunk); > } > else > { > fwrite(chunk, sizeof(entry), fromLastChunkHowMuch, pChunk); > } > fclose(pChunk); > */ > ifstream novyStream(filename.c_str(), ios::binary | ios::in); > chunks.push_back(novyStream); > //chunks.emplace_back(filename.c_str(), ios::in | ios::binary); > >} > >int main() >{ > > /* > // 1. Reading and writing into binary subfiles > beginning = clock(); > ios_base::sync_with_stdio(false); > ifstream vstup(INPUTFILENAME); > int lc = 0; > uint64_t item = 0; > uint64_t key = 0; > uint64_t value = 0; > size_t chunkPosition = 0; > char buf[2048]; > do > { > vstup.read(buf, sizeof(buf)); > std::streamsize k = vstup.gcount(); > for (std::streamsize i = 0; i < k; ++i) > { > switch (buf[i]) > { > case '\r': > break; > case '\n': > value = item; > chunk[chunkPosition] = entry(key, value); > chunkPosition++; > if (chunkPosition == ENTRIES_IN_MEMORY) > { > dumpChunk(); > chunkIndex++; > chunkPosition = 0; > } > item = 0; lc++; > break; > case ' ': > key = item; > item = 0; > break; > case '0': case '1': case '2': case '3': > case '4': case '5': case '6': case '7': > case '8': case '9': > item = 10 * item + buf[i] - '0'; > break; > } > } > } while (vstup); > vstup.close(); > fromLastChunkHowMuch = chunkPosition; > if (fromLastChunkHowMuch != 0) > { > dumpChunk(); > chunkIndex++; > } > std::cout << "Phase 1 complete." << timestring() << endl; > > // 2. Merge > std::priority_queue<std::tuple<entry, size_t> > fronta; > FILE* pFinal = fopen(OUTPUTFILENAME, "w"); > for (size_t i = 0; i < chunks.size(); i++) > { > entry firstEntry; > chunks[i].read((char*)&firstEntry, sizeof(entry)); > fronta.push(std::tuple<entry, size_t>(firstEntry, i)); > } > while (!fronta.empty()) > { > std::tuple<entry, size_t> vrsek = fronta.top(); > fprintf(pFinal, "%" SCNu64 " %" SCNu64 "\n", get<0>(vrsek).key, get<0>(vrsek).value); > fronta.pop(); > entry newEntry; > if (chunks[get<1>(vrsek)].read((char*)&newEntry, sizeof(entry))) > { > fronta.push(tuple<entry, size_t>(newEntry, get<1>(vrsek))); > } > } > fclose(pFinal); > std::cout << "Phase 2 complete." << timestring() << endl; > */ > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 525442
: 386692