RE: JESS: [EXTERNAL] bsave fails after defquery execution [was: Dynamic rule-base analysis]
"Friedman-Hill, Ernest" <[email protected]> Tue, 1 Oct 2013 02:44:58 +0000
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <[email protected]> |
It would certainly make sense for this class to be Serializable, as most = other classes in Jess are. The current implementation in practice contain= s an instance of java.util.ArrayList.Itr, which is not Seriaizable, so a = certain amount of coding would be involved in making this change. Worth d= oing, though, so I'll see if we can work it in. -----Original Message----- From: [email protected] [mailto:[email protected]] On= Behalf Of Jonathan Sewall Sent: Monday, September 30, 2013 9:49 AM To: jess-users Subject: JESS: [EXTERNAL] bsave fails after defquery execution [was: Dyna= mic rule-base analysis] [Apologies for the incorrect Subject: on this report yesterday, 9/29.] The trouble with bsave after executing a defquery appears to happen when = serializing the Map Context.m_variables in Rete.m_globalContext: at this = point in the script, the map holds the QueryResult variable ?qr: (bind ?qr (run-query* all-cars)) Hence, if I execute (bind ?qr "not a QueryResult") before the 2nd bsave, then the script runs without error. Could QueryResu= lt be made Serializable? Revised script and results below.=20 Thanks again, Jonathan Sewall ------- Original Message -------- Subject: Re: JESS: [EXTERNAL] Dynamic rule-base analysis Date: Sun, 29 Sep 2013 18:04:11 -0400 From: Jonathan Sewall <[email protected]> Reply-To: [email protected], [email protected] To: [email protected] ... Contents of script.clp: (deftemplate car (slot make) (slot model)) (defquery all-cars "Get all ca= rs." ?car <- (car)) (defquery cars-of-make "Get cars of the given make." = (declare (variables ?want-make)) ?car <- (car (make ?m&:(=3D ?m ?want-make)))) (reset) (bind ?pickup (assert (car (make "Ford") (model "F100")))) (bind ?sedan (= assert (car (make "Honda") (model "Civic")))) (bind ?suv (assert (car (ma= ke "Ford") (model "Explorer")))) (printout t "*** Before 1st bsave ***" c= rlf) (printout t "globalContext " (((engine) getGlobalContext) toString) = crlf) (bsave "s1.bsave") (bind ?qr (run-query* all-cars)) (while (?qr nex= t) (bind ?car (?qr getObject "car")) (printout t (?car toString) crlf)) (?qr close) (printout t "*** Before 2nd bsave ***" crlf) (printout t "globalContext "= (((engine) getGlobalContext) toString) crlf) ;; (bind ?qr "not a QueryRe= sult") ;; uncomment to make script run ok (bsave "s2.bsave") Results: $ java -cp lib/jess.jar jess.Main Jess, the Rule Engine for the Java Platform Copyright (C) 2008 Sandia Cor= poration Jess Version 7.1p2 11/5/2008 Jess> (batch "script.clp") *** Before 1st bsave *** globalContext [Context, 3 variables:=20 pickup=3D<Fact-1>;sedan=3D<Fact-2>;suv=3D<Fact-3>;] (MAIN::car (make "Ford") (model "F100")) (MAIN::car (make "Honda") (model= "Civic")) (MAIN::car (make "Ford") (model "Explorer")) *** Before 2nd bsave *** globalContext [Context, 5 variables:=20 car=3D<Java-Object:jess.Fact>;pickup=3D<Fact-1>;sedan=3D<Fact-2>;suv=3D<F= act-3>;qr=3D<Java-Object:jess.QueryResult>;] Jess reported an error in routine bsave while executing (bsave "s2.bsave") while executing (batch "script.clp"). Message: IO Exception. Program text: ( bsave "s2.bsave" ) at line 17 in file script.clp. Nested exception is: jess.QueryResult Jess> -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [email protected]' in the BODY of a message to [email protected], NOT to the list (use yo= ur own address!) List problems? Notify [email protected]. -------------------------------------------------------------------- -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [email protected]' in the BODY of a message to [email protected], NOT to the list (use your own address!) List problems? Notify [email protected]= . --------------------------------------------------------------------