メモリ マップド ファイルを使用します。これは非常識に聞こえるかもしれませんが (パフォーマンスに関して)、いくつかの巧妙なトリックを使用すると、そうではないかもしれません。
- ファイル内でバイナリ検索を使用してレコードを検索できるように、キーを並べ替えます。
- ファイルの各行を同じ長さにするようにしてください (「固定幅レコード」)。
固定幅レコードを使用できない場合は、次の疑似コードを使用してください。
Read 1KB in the middle (or enough to be sure the longest line fits *twice*)
Find the first new line character
Find the next new line character
Get a line as a substring between the two positions
Check the key (first 40 bytes)
If the key is too big, repeat with a 1KB block in the first half of the search range, else in the upper half of the search range
パフォーマンスが十分でない場合は、C で拡張機能を作成することを検討してください。