Search code examples
savejessrete

What exactly does bsave, save in Jess?


I am quite new to Jess and am looking into persisting the Rete algorithm. It's come to my attention that in Jess there is the bsave function that saves the rete object, but what exactly does that mean? Does it save the facts, functions and rules and then it has to iterate over the network again to do the matches or does it save everything, including the intermediary matches, which would imply that when you load it, provided that no modifications were done to the WM, the engine should be ready to go?


Solution

  • The function bsave and the Rete method bsave serialize the state of the Rete object. This means that you can execute function, terminate the session, destroy the Rete object, start another session, load the state using bload to return to the state where you did bsave.

    Saving the state includes the state of the Rete network, including the agenda. So, if you have called run before saving, calling run after loading won't fire any rules.

    Calling facts, for instance, produces a list of facts as they were at the moment of calling bsave etc.

    See the documentation of bload for things not included in the snapshot.