I'm on windows, and I'll work only with windows.
I have a question about opening big files (PTX).
On each line, I will have the coordinates of a points X Y Z I {R G B}
({R, G, B} are not forced to be present).
Since my files are huge (sometimes > 100Go), I would like to read them fastly using memory map (I never did that before), or at least read chunck of memory instead of reading it line by line.
My question is : if I read chunck of memory using
ifstream bigFile("mybigfile.dat");
constexpr size_t bufferSize = 1024 * 1024;
unique_ptr<char[]> buffer(new char[bufferSize]);
while (bigFile)
{
bigFile.read(buffer.get(), bufferSize);
// process data in buffer
}
for example, is there a way to be sure that my buffer won't stop in the middle of a line?
For example, my files is
x1 y1 z1 i1 r1 g1 b1
x2 y2 z2 i2 r2 g2 b2
x3 y3 z3 i3 r3 g3 b3
x4 y4 z4 i4 r4 g4 b4
x5 y5 z5 i5 r5 g5 b5
and I want to create a std::vector<Point>
. So I read a buffer size of this file, put it in the buffer, and then I take data from buffer to create my points. But how can I be sure that the buffer won't stop at r3
?
If the buffer contains x1 y1 z1 i1 r1 g1 b1 x2 y2 z2 i2 r2 g2 b2 x3 y3 z3 i3 r3
I can't create a point using only x3, y3, z3, i3, r3
. I would need g3
and b3
too.
Is there a way to take care of that? I hope that it is understandable, English isn't my native language and I'm not sure I explained it well...