Is it possible to reverse lookup the index position for itersorted in PyTables?

我是研究僧i 提交于 2019-12-02 08:12:23

问题


Context

Multi GB database with a simple table that has a column with a completely sorted index (CSI). To iterate through the index without loading all the rows in a batch like where we can:

for row in itersorted('indexed_column', step=1):
    print row

This works fine, the next step can be to iterate from a certain index position like:

for row in itersorted('indexed_column', start=position, step=1):
    print row

Now the caveat: that position is the position in the index and not the row number! And it is very easy to find row numbers (Row.nrow) with where, get_where_list, etc.

Problem

Is it possible to do a fast reverse lookup of the index position of a certain value of the indexed column for itersorted(start=position) to be useful?

Attempts

  • table.cols.indexed_column.index finds the index class but was a dead end.
  • Alternatively, as said, is to do several queries using the index with where queries. But since I am simulating a stream and itersorted(start=position) exists I was hoping there was a more elegant way.

来源:https://stackoverflow.com/questions/22202841/is-it-possible-to-reverse-lookup-the-index-position-for-itersorted-in-pytables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!