且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用iPhone应用程序发送120万条记录

更新时间:2023-01-28 20:32:58

文本文件的集合可以很好地工作。你可以:

a collection of text files could work well. you can:


  • 将它们分成多个文件(例如通过前导字符范围)。

  • order适当配对(例如按字符编号)

  • 并根据情况快速/轻松地逐步/部分读取。

  • 平衡文件读取和内存使用之间的资源。

  • 为字符串选择正确的编码也有帮助(如果它主要在ascii中,我会从utf8开始)。

  • divide them into multiple files (e.g. by leading character range).
  • order pairs appropriately (e.g. by character number)
  • and quickly/easily read incrementally/portions as appropriate.
  • balance resources between file reads and memory usage well.
  • choosing the right encoding for the strings can also help (i'd start with utf8 if it's mostly in ascii).

如果分配大小也是您关注的问题,您可以压缩/解压缩这些文件。

if distribution size is also your concern, you could compress/decompress these files.

或者您可以采用这种方法并使用自定义序列化类,表示集合的子集,如果听起来像是太多的解析和读取实现。

or you can just take this approach and use a custom serialized class to represent a subsets of the collection if that sounds like too much parse and read implementation.

如果你使用objc类型进行存储和/或解析,那么保持这些文件小是好的。如果你使用c或c ++,那么它将有助于分析应用程序。

if you're using objc types for storage and/or parsing, then it would be good to keep those files small. if you use c or c++, then it would help to profile the app.

你的数据集需要使用每字符8位单字节编码最多30 MB。一个大文件(再次,有序),你mmap也值得考虑。参见 [NSData initWithContentsOfMappedFile:path];

your data set will require up to 30 MB using an 8 bit per character single byte encoding. one large file (again, ordered) which you mmap would also be worth consideration. see [NSData initWithContentsOfMappedFile:path];.