[rules-users] Comparing KnowledgePackages for Equality

Wolfgang Laun wolfgang.laun at gmail.com
Fri Mar 22 12:38:05 EDT 2013


I can understand why the sequence
   compile -> serialize to a.pkg -> deserialize -> serialize to b.pkg
is almost bound to create a.pkg != b.pkg. (readObject is inclined to use
capacity data for optimized resource allocation.)

I have seen that
  compile -> serialize to a.pkg
  compile -> serialize to b.pkg
in separate runs creates a.pkg != b.pkg. And I've verified that
   x.pkg -> deserialize -> serialize to a.pkg
   x.pkg -> deserialize -> serialize to b.pkg
produces a.pkg != b.pkg.

Conclusion: there's no way of comparing compiled packages.

-W



On 21/03/2013, gqmulligan <gqmulligan at gmail.com> wrote:
> I am using Drools 5.3.1.Final in case that is useful information.
>
> Thanks Esteban for the suggestion but I could not get that to work.  I must
> be doing something wrong.  Here is what I am trying to do in a nutshell.
>
> I read in several standard rules and guided rules, add them all to a
> KnowledgeBuilder,  and then get the resulting KnowledgePackage from the
> KnowledgeBuilder.  I then save this KnowledgePackage to a database using
> Hibernate.  My problem is now every time I read the package from the
> database Hibernate thinks the object is dirty and updates the rule package.
>
> A byte comparison of two packages does not work because you are not
> guaranteed everything in the package will be serialized in the same order,
> as I found.  To test this I deserialized two packages from the same byte
> stream, serialized them, and all resulting byte arrays were different.
>
> When I tried Esteban's idea I read the KnowledgePackage from the database
> but all the rules in the package do not have a consequence until I add the
> package to a KnowledgeBase.  This means that I cannot use a
> BinaryResourceDiffProducerImpl because that compares rule consequences and
> throws a NullPointerException in my case.
>
> Any other ideas on how I can successfully compare two KnowledgePackages
> that
> represent the same set of rules or even another suggestion altogether to
> get
> KnowledgePackages to play nicely with Hibernate?
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Comparing-KnowledgePackages-for-Equality-tp4022952p4022979.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list