Merge lp:~therve/storm/fix-compile-cache into lp:storm

Proposed by Thomas Herve
Status: Merged
Merged at revision: 409
Proposed branch: lp:~therve/storm/fix-compile-cache
Merge into: lp:storm
Diff against target: 59 lines (+11/-5)
1 file modified
storm/expr.py (+11/-5)
To merge this branch: bzr merge lp:~therve/storm/fix-compile-cache
Reviewer Review Type Date Requested Status
Jamu Kakar (community) Approve
Storm Developers Pending
Review via email: mp+75391@code.launchpad.net

Description of the change

The problem here is that we use the same compile cache for different backends. It's likely to only happen in storm test suite, but I solved it in a generic way anyway using the compiler to identify the cache.

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

Nice one, +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'storm/expr.py'
--- storm/expr.py 2011-09-14 15:27:52 +0000
+++ storm/expr.py 2011-09-14 17:58:01 +0000
@@ -801,7 +801,7 @@
801 according to this column.801 according to this column.
802 """802 """
803 __slots__ = ("name", "table", "primary", "variable_factory",803 __slots__ = ("name", "table", "primary", "variable_factory",
804 "compile_cache")804 "compile_cache", "compile_id")
805805
806 def __init__(self, name=Undef, table=Undef, primary=False,806 def __init__(self, name=Undef, table=Undef, primary=False,
807 variable_factory=None):807 variable_factory=None):
@@ -810,6 +810,7 @@
810 self.primary = int(primary)810 self.primary = int(primary)
811 self.variable_factory = variable_factory or Variable811 self.variable_factory = variable_factory or Variable
812 self.compile_cache = None812 self.compile_cache = None
813 self.compile_id = None
813814
814@compile.when(Column)815@compile.when(Column)
815def compile_column(compile, column, state):816def compile_column(compile, column, state):
@@ -821,14 +822,16 @@
821 alias = state.aliases.get(column)822 alias = state.aliases.get(column)
822 if alias is not None:823 if alias is not None:
823 return compile(alias.name, state, token=True)824 return compile(alias.name, state, token=True)
824 if column.compile_cache is None:825 if column.compile_id != id(compile):
825 column.compile_cache = compile(column.name, state, token=True)826 column.compile_cache = compile(column.name, state, token=True)
827 column.compile_id = id(compile)
826 return column.compile_cache828 return column.compile_cache
827 state.push("context", COLUMN_PREFIX)829 state.push("context", COLUMN_PREFIX)
828 table = compile(column.table, state, token=True)830 table = compile(column.table, state, token=True)
829 state.pop()831 state.pop()
830 if column.compile_cache is None:832 if column.compile_id != id(compile):
831 column.compile_cache = compile(column.name, state, token=True)833 column.compile_cache = compile(column.name, state, token=True)
834 column.compile_id = id(compile)
832 return "%s.%s" % (table, column.compile_cache)835 return "%s.%s" % (table, column.compile_cache)
833836
834@compile_python.when(Column)837@compile_python.when(Column)
@@ -876,16 +879,19 @@
876879
877880
878class Table(FromExpr):881class Table(FromExpr):
879 __slots__ = ("name", "compile_cache")882 __slots__ = ("name", "compile_cache", "compile_id")
880883
881 def __init__(self, name):884 def __init__(self, name):
882 self.name = name885 self.name = name
883 self.compile_cache = None886 self.compile_cache = None
887 self.compile_id = None
888
884889
885@compile.when(Table)890@compile.when(Table)
886def compile_table(compile, table, state):891def compile_table(compile, table, state):
887 if table.compile_cache is None:892 if table.compile_id != id(compile):
888 table.compile_cache = compile(table.name, state, token=True)893 table.compile_cache = compile(table.name, state, token=True)
894 table.compile_id = id(compile)
889 return table.compile_cache895 return table.compile_cache
890896
891897

Subscribers

People subscribed via source and target branches

to status/vote changes: