Efficiently reading a very large text file in C++

前端 未结 4 1680
攒了一身酷
攒了一身酷 2020-12-02 16:13

I have a very large text file(45GB). Each line of the text file contains two space separated 64bit unsigned integers as shown below.

4624996948753406865 10214715013

4条回答
  •  余生分开走
    2020-12-02 16:36

    You can memory map the file into memory, but that would be platform dependent (on unix that would be mmap on windows CreateFileMapping/MapViewIntoFile); still if in 32 bit system you may have problems if there is not a big enough virtual memory block left (64 bit systems would not have that problem).

    Memory mapping is supposed to be faster than reading the data block by block from disk.

提交回复
热议问题