使用iPhone应用程序发送120万条记录 [英] Shipping 1.2 million records with an iPhone app

查看:74
本文介绍了使用iPhone应用程序发送120万条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有120万个键值对的数据集。键是一个字符串(一个长度最多为22个字符的数字序列),值是字符串。

I have a data set of 1.2 million key-value pairs. The keys are a string (a sequence of numbers up to 22 characters in length), and the values are strings.

最好的方法是什么,这样一个值可以是否可以快速查找并检索?

What's the best way to ship this so a value can be looked up and retrieved quickly?

我怀疑一个plist不适合这种大小的数据集。

I suspect a plist is not the way to go for a data set this size.

我有两种存储方式的数据集 - CSV和带有2列的mySQL数据库表。 I
ll继续使用任何方法将数据最好地导入应用程序。

I have the data set stored in two ways - a CSV, and a mySQL database table with 2 columns. I ll go forward using whatever method gets the data into the app the best.

推荐答案

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

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];.

这篇关于使用iPhone应用程序发送120万条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆