Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

storing pointers to line numbers of a file stored on disk in C++

Tags:

c++

c

I want to store pointers to file's line numbers in an array and later I want to retrieve the specified line from disk. I can not store pointer to line number directly as when I read the file back the memory locations would have changed. So, I am storing the offset from the beginning of the file instead. For storing the offset I am using "uint_64t". However since my file size is 200GB therefore "uint_64t" is not able to represent all the offsets.

I have the following questions:

  1. Other than storing offsets, is there some other way by which I may store pointers to file stored on disk.

  2. Is there some other data structure which I may use (other than uint64_t).

like image 215
Rose Beck Avatar asked Nov 29 '22 12:11

Rose Beck


1 Answers

On POSIX systems, off_t is the standard type for file offsets. It's probably a 64-bit type, though, just like uint64_t, as those can hold values on the order of 2e11 without trouble.

like image 100
Fred Foo Avatar answered Dec 05 '22 01:12

Fred Foo