Multiple ifstreams vs ifstream + constant search

I am writing a merge look. It works like this: read k pieces from a large file, sort them in memory, merge k-way, do it. Therefore, I need to read sequentially from different parts of the file during the k-way merge phase. What is the best way to do this: multiple ifstream or one ifstream and search? Also, is there a library for simple asynchronous I / O?

+3
source share
2 answers

Use one ifstreamat a time in one file. Several resources are lost and you still have to search (because by default the file pointer ifstreamstarts at the beginning of the file).

++ async IO, .

EDIT: , ( ). , ifstream , pubsetbuf(0, 0); , . , ifstream . .

+2

. , , ( , , ), , .

, . k = 2.

, , (ulimit -n). , , k- .

mmapping , (: ).

+1

Source: https://habr.com/ru/post/1741927/


All Articles