D
David Breton
Hi,
I have a few questions about ifstream and file i/o in general.
Say I open a file stream with this command:
ifstream in;
in.open("file.dat", ios::in|ios::binary);
1) Is any part of file.dat loaded in memory at this point?
If I now do:
in.seekg(sizeof(long)*1000000);
in.read((char*)l, sizeof(long));
2) Roughly how much of the file is in, or went through, memory?
3) What is the time complexity of in.seekg(n)?
Is it O(1), O(n), something else, or does it depend on the hardware?
Also if anyone could point me to a url where I can find answers to such
questions, it would be appreciated.
If you want to know, I'm asking because I have a large file, about
200GB, which contains nothing but longs. Given a number 'k' I want to
efficiently retrieve the k_th long stored in the file.
Thanks,
David
I have a few questions about ifstream and file i/o in general.
Say I open a file stream with this command:
ifstream in;
in.open("file.dat", ios::in|ios::binary);
1) Is any part of file.dat loaded in memory at this point?
If I now do:
in.seekg(sizeof(long)*1000000);
in.read((char*)l, sizeof(long));
2) Roughly how much of the file is in, or went through, memory?
3) What is the time complexity of in.seekg(n)?
Is it O(1), O(n), something else, or does it depend on the hardware?
Also if anyone could point me to a url where I can find answers to such
questions, it would be appreciated.
If you want to know, I'm asking because I have a large file, about
200GB, which contains nothing but longs. Given a number 'k' I want to
efficiently retrieve the k_th long stored in the file.
Thanks,
David