Ticket #193 (closed defect: fixed)

Opened 2 months ago

Last modified 2 months ago

Incorrect handling of dirty indexes in queries

Reported by: faltet Owned by: somebody
Priority: major Component: PyTables Pro
Version: Keywords:
Cc:

Description

There is a problem in the condition cache when handling dirty indexes. The next code snippet exposes the problem:

import tables

class Rec(tables.IsDescription):
    a = tables.IntCol()
    b = tables.FloatCol()

f = tables.openFile("/tmp/hola.h5", "w")
t = f.createTable(f.root, "t", Rec)

row = t.row
for i in range(10):
    row['a'] = i
    row['b'] = i
    row.append()
t.flush()

res1 = [row['a'] for row in t.where("(a > 2) & (b < 5)")]
print "res1-->", res1

# Create indexes for columns
t.cols.a.createIndex()
t.cols.b.createIndex()

res2 = [row['a'] for row in t.where("(a > 2) & (b < 5)")]
print "res2-->", res2

# Make the column indexes dirty
for row in t:
    if row.nrow == 3:
        row['a'] = 1
        row['b'] = 0
        row.update()
#t.flush()  # Flushing the table removes the index dirtiness

res3 = [row['a'] for row in t.where("(a > 2) & (b < 5)")]
print "res3-->", res3

f.close()

And the output is:

res1--> [3, 4]
res2--> [3, 4]
Traceback (most recent call last):
  File "/tmp/prova.py", line 33, in <module>
    res3 = [row['a'] for row in t.where("(a > 2) & (b < 5)")]
  File "/home/faltet/PyTables/pytables/PyTablesPro/trunk/tables/table.py", line 1194, in where
    return self._where(condition, condvars, start, stop, step)
  File "/home/faltet/PyTables/pytables/PyTablesPro/trunk/tables/table.py", line 1216, in _where
    self, compiled, condvars, start, stop, step)
  File "/home/faltet/PyTables/pytables/PyTablesPro/trunk/tables/_table_pro.py", line 185, in _table__whereIndexed
    assert not index.dirty, "the chosen column has a dirty index"
AssertionError: the chosen column has a dirty index
Closing remaining open files: /tmp/hola.h5... done

when it should be:

res1--> [3, 4]
res2--> [3, 4]
res3--> [4]

Change History

Changed 2 months ago by faltet

Fixed in r3890.

Changed 2 months ago by faltet

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.