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