RDFLib/rdflib — Issue #77: ZODB backend fails to remove triples
Author: gjhiggins
Created: 2012-02-20 08:32:07+00:00
State: closed

jus...@onebrightspace.com, 2009-09-01T09:29:08.000Z

What steps will reproduce the problem?
1. Use ZODB backend.
2. Add a number of triples.
3. call remove((None, None, None))

What is the expected output? What do you see instead?
Expected: All triples removed
Actual: Only a percentage of the triples are removed.

What version of the product are you using? On what operating system?
2.4.1

Please provide any additional information below.
The ZODB backend uses IOMemory. The remove() method calls triples() to get
a list of triples to remove. The triples method yields the results from a
{}.keys(); which is normally a list in Python, however on a BTree this
results in an iterable object. Because the remove() method is then looping
around an iterable list and not a static list, the size of the list shrinks
as items are removed, resulting in missed triples and general odd behaviour.

Fix is to explicitly list() the tiples call in remove:

for triple, cg in list(self.triples(triple)):

This may be a rather large list, but the alternative is to list() the
keys() call in the triples method. The triple method is likely to be used
a lot more than remove, so forcing it to list everything on the keys() call
will slow it down.

Comment 1 by eik...@gmail.com

Comment 2 by eik...@gmail.com

Comment 3 by eik...@gmail.com
No longer part of rdflib; at least for now.