<alert comment="newbie">
I'm converting an app from Windows-Desktop and PPC that involves
reading and then repeated searches of a 4 meg text file that consists
of 30,000+ lines. (e.g. show the lines that have the word "test" in
them, then "hello", etc.)
This newbie is very fuzzy on the best way to proceed. I don't think a
database of 30,000 records is appropriate, as I suspect there will be
too much overhead to fetch individual records. Searches will probably
be too slow.
I've used the "par" program to convert the test.dat file to test.pdb
and put that on the 5.4 simulator.
I've gotten a small version working with CW9.3 that uses FtrPtrNew to
allocate a buffer, but it doesn't seem possible to use that buffer for
the FileRead call. I want to avoid having several 4 meg buffers to get
the file into memory.
Err errCode;
void* ftrMemP = NULL;
UInt16 myFtrMemFtr = 1234;
FileHand fh = FileOpen(0, "test.pdb", 0, 0, fileModeReadOnly,
&errCode);
if (fh != 0) {
errCode = FtrPtrNew(appFileCreator, myFtrMemFtr, 4000000,
&ftrMemP);
if (errCode == 0) {
Int32 charsRead = FileRead(fh, ftrMemP, 1, 4000000, &errCode);
// crashes
errCode = FtrPtrFree (appFileCreator,myFtrMemFtr);
}
FileClose(fh);
}
The above fails because DmWrite must be used to actually put contents
into ftrMemP;
Am I better off having the file located on external memory (such as an
SD card) and using VfsFileRead to get the contents info the ftrMemP?
My impression is that the read from a file will be slower, but less
memory will be used. I want the app to "launch" quickly, but after
that, the highest priority is for searches to be fast (under a second
... preferably less than 0.5 sec).
Also, I'm unclear about the purpose of the featureNum parameter to the
Ftr calls. The sample code I found seemed to use an arbitrary number
(like the 1234 above). Is there an appropriate number to use for
FtrPtrNew?
</alert>
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/