文件索引(使用二叉树?)在Python索引、文件、二叉树、Python

2023-09-11 04:49:49 作者:闹够了就滚

我有一个标准的野外基于格式的数据文件(想想制表符分隔,在每一行相同的字段,在每个文件)很多(千!)。我辩论使该数据可/可搜索的各种方法。 (有些选项包括RDBMS,NoSQL的东西,在使用grep / awk的朋友,等等)。

I have many (thousands!) of data files with a standard field based format (think tab-delimited, same fields in every line, in every file). I'm debating various ways of making this data available / searchable. (Some options include RDBMS, NoSQL stuff, using the grep/awk and friends, etc.).

在特别地,一个想法,吸引我的是索引以某种方式的文件。由于这些文件是只读的(静态),我想象一些持久性文件包含二进制树(每个索引字段,就像在其他的数据存储)。我接受有关如何想法,这一点,或听到,这简直是疯了。最主要的是,我最喜爱的搜索引擎还没有产生使我适合这份任何pre-推出的解决方案。

In particular, one idea that appeals to me is "indexing" the files in some way. Since these files are read-only (and static), I was imagining some persistent files containing binary trees (one for each indexed field, just like in other data stores). I'm open to ideas about how to this, or to hearing that this is simply insane. Mostly, my favorite search engine hasn't yielded me any pre-rolled solutions for this.

我意识到这是一个有点病态形成的,解决方案是值得欢迎的。

I realize this is a little ill-formed, and solutions are welcome.

文件长,不宽 在数以百万计,每小时线,S $ P $垫时速超过100个文件 标签分隔,没​​有多少列(〜10) 字段是短(说&LT;每场50个字符) files long, not wide millions of lines per hour, spread over 100 files per hour tab seperated, not many columns (~10) fields are short (say < 50 chars per field)

(所有这些都是基于我的观察和测试,但我愿意修正)

(All of these are based on my observations and tests, but I'm open to correction)

BDB

有问题扩展到大的文件大小(以我的经验,一旦他们2GB左右,表现可以用糟糕) 在单一的作家(如果有可能解决这个问题,我想看看code!) 很难做到多个索引,也就是说,索引在不同的领域,在一次(确保你可以通过复制数据一遍又一遍这样做)。 ,因为它仅存储字符串,有一个序列化/反序列化步

RDBMS中

荣获:的

在平坦的桌面模式是优秀的查询,检索

损失:的

在我的经验,这个问题带有索引。从我所看到的(并请纠正我,如果我错了),这个问题与RDBMS中,我知道(源码,Postgres的)支持两种批量加载(然后索引是在年底慢)按行装载,或行(这是低)。也许我需要更多的性能优化。

推荐答案

为什么要推倒重来?通过一切手段,索引文件,但使用嗖或的 Lucene的等。

Why reinvent the wheel? By all means, index the files, but use Whoosh, or Lucene, etc.

编辑:你没有在我贴这个答案的时候说你的性能要求。你不会是能够索引数以百万计,每小时行有现成的,现成的软件。

you hadn't stated your performance requirements at the time I posted this answer. You're not going to be able to index "millions of rows per hour" with off-the-shelf software.

 
精彩推荐
图片推荐