JimHagan / pygrametl

Automatically exported from code.google.com/p/pygrametl
BSD 2-Clause "Simplified" License
0 stars 1 forks source link

It seems that pygrametl's cache caches negative lookups. Not sure if it's supposed to be that way #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
tables.py, line 471 (using r47)

if resultkey is not None:

If defaultidvalue is used, resultkey is never None, but rather defaultidvalue 
for failed lookup.

When used with CachedDimension, this leads to caching results of failed lookups.
That's not what I expect - but may be it supposed to be that way.

I added

if self.defaultvalue is not None and resultkey != self.defaultidvalue:

after the above line in my copy (and reindented. Ain't python a great language 
to work with!), and it works for me. 

May be you should add it to upstream, if it makes sense to you guys.

Original issue reported on code.google.com by d...@parallels.com on 6 Apr 2015 at 4:12

GoogleCodeExporter commented 9 years ago
Not supposed to be "defect", but I couldn't find the "Type" anywhere in "submit 
new issue. Sorry about that

Original comment by d...@parallels.com on 6 Apr 2015 at 4:14

GoogleCodeExporter commented 9 years ago
not self.defaultvalue, but self.defaultidvalue of course.

if self.defaultidvalue is not None and resultkey != self.defaultidvalue:

Original comment by d...@parallels.com on 6 Apr 2015 at 4:27

GoogleCodeExporter commented 9 years ago
Thanks for the suggestion.

But why not cache "negative lookups"? By caching that a lookup failed, we can 
avoid to do the same lookup later and thus save a round-trip to the database.

Original comment by c...@cs.aau.dk on 7 Apr 2015 at 9:00