04-28-2005, 09:09 PM
I'm reading .DBF files from disk, and creating an index to the
records in memory. I am storing the fields of the database
file which constitute the unique key to the record in an array
by concatenting the fields into a single string, loading each
string into an array where the number of elements = the number
of records in the file, and then sorting the resulting array. So I
end up with a string array sorted in ascending order based on the
ascii value of each element. I also keep a pointer for each of
these elements to the record number of the file.
Each element of the array is always going to be a fixed length,
since the .DBF file defines fixed widths for each field -- but I won't
know the fields' widths until I open the file and read the .DBF
header, so I can't code a constant width. The value of the width
would never change once I have the file open, but I can't predict
the width of the fields until I open the file. Else, I have to modify
the code for every time file structures change -- not acceptable.
So, depending on the number of records in the .DBF file, and the
number of .DBF files that have to remain open at one time, I need
to conserve memory as much as possible. If my index to the record
is only 15 bytes, I'd like to use up 15 bytes of memory for each
element of the string array.
Dean
records in memory. I am storing the fields of the database
file which constitute the unique key to the record in an array
by concatenting the fields into a single string, loading each
string into an array where the number of elements = the number
of records in the file, and then sorting the resulting array. So I
end up with a string array sorted in ascending order based on the
ascii value of each element. I also keep a pointer for each of
these elements to the record number of the file.
Each element of the array is always going to be a fixed length,
since the .DBF file defines fixed widths for each field -- but I won't
know the fields' widths until I open the file and read the .DBF
header, so I can't code a constant width. The value of the width
would never change once I have the file open, but I can't predict
the width of the fields until I open the file. Else, I have to modify
the code for every time file structures change -- not acceptable.
So, depending on the number of records in the .DBF file, and the
number of .DBF files that have to remain open at one time, I need
to conserve memory as much as possible. If my index to the record
is only 15 bytes, I'd like to use up 15 bytes of memory for each
element of the string array.
Dean