in reply to Re^2: Using indexing for faster lookup in large file (PP < 0.0005s/record)
in thread Using indexing for faster lookup in large file
But I'm thinking that the first snippet of code walks through the data and gets the position, in bytes, for each starting number?
Correct. (But that "snippet" is a complete working program to create the index file. You did run that first didn't you?)
Also running the code you wrote as-is only produced "Not found" for me.
The first thing that comes to mind is that you never answered my question above about the sort order of your data files.
If they are not sort numerically, then you will need to sort the file; or the index file; before the binary search will work.
It's seems as if the indexing might not catch what I would like since it won't find anything I'm looking for.
I'll need a little more information to go on.
Could you run the following steps in your console and copy&paste the output (in <code></code> tags).
Substitute whatever names you gave to the two programs above for 1118102-indexer.pl & 1118102-indexer.pl below.
The test file need only be a few dozen lines; but the lines must start with numbers, and it must be sorted numerically. The 200 sample lines you posted above would be ideal. :
>perl -V >1118102-indexer smallFile.txt smallFile.idx >1118102-searcher -N=10 smallFile.txt smallfile.idx
If you post the output from all 3 commands, it might give some clues as to what is going on.
|
|---|