Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 68781 invoked from network); 18 Feb 2009 16:03:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Feb 2009 16:03:53 -0000 Received: (qmail 72802 invoked by uid 500); 18 Feb 2009 16:03:52 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 72751 invoked by uid 500); 18 Feb 2009 16:03:52 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 72742 invoked by uid 99); 18 Feb 2009 16:03:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2009 08:03:52 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [198.76.24.140] (HELO WSTEXCH00.westminster.polycom.com) (198.76.24.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2009 16:03:44 +0000 Received: from wstexch03.westminster.polycom.com ([10.1.10.45]) by WSTEXCH00.westminster.polycom.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Feb 2009 09:03:38 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C991E2.75BDF5AB" Subject: RE: [SHARED] Is there an easy way to compare filters, some with OID and some without? Date: Wed, 18 Feb 2009 09:03:38 -0700 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SHARED] Is there an easy way to compare filters, some with OID and some without? Thread-Index: AcmR3v1xqyA2lFqhQ4K5d4JelZ/O4AAA2BsQ From: "Hammond, Steve" To: "Apache Directory Developers List" X-OriginalArrivalTime: 18 Feb 2009 16:03:38.0188 (UTC) FILETIME=[75CE98C0:01C991E2] X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01C991E2.75BDF5AB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Great! =20 I have one question. Why do you suggest dumping to a string to compare when there is an equals function on ExprNode already? =20 ________________________________ From: Alex Karasulu [mailto:akarasulu@gmail.com]=20 Sent: Wednesday, February 18, 2009 8:38 AM To: Apache Directory Developers List Subject: Re: [SHARED] Is there an easy way to compare filters, some with OID and some without? =20 =20 On Wed, Feb 18, 2009 at 10:25 AM, Hammond, Steve wrote: I am trying to compare 2 filters (ExprNode), it happens to be an and clause, but that is irrelevant. =20 So my code is if ( filter.equals(groupUnimported)) // special filter case. =20 The problem is that when it gets to this code filter =3D (&(2.5.4.0=3Dgroup)(!(1.2.840.113556.1.4.26=3D-1))) And groupUnimported=3D (&(objectClass=3Dgroup)(!(ugpid=3D-1))) =20 I can look at those and know they are equal. Is there some normalizer I can run the 2 ExprNodes thru before doing the equals? I don't want to do 4 separate equals tests, especially if we start to get bigger filters that end up as special cases. You're in luck Steve. You can use the following visitor implementation to perform normalized comparisons of filter expressions. This was specifically written to match for equivalent logical expressions that may have term order variations. Here take a look: http://ahkaek.notlong.com/ This BranchNormalizedVisitor will normalize the order of terms in a filter branch (OR / AND nodes only) without effecting the logic of the filter. After doing this the filter can be dumped to a string and compared.=20 In addition to this you'll want to normalize attributes to OID's which is easy to do if you have access to the schema. Just write another visitor to change the attribute alias names in leaf nodes to their respective OID value using the lookup method in AttriuteTypeRegistry. HTH, Alex ------_=_NextPart_001_01C991E2.75BDF5AB Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Great!

 

I have one question.  Why do = you suggest dumping to a string to compare when there is an equals function on = ExprNode already?

 


From: Alex = Karasulu [mailto:akarasulu@gmail.com]
Sent: Wednesday, February = 18, 2009 8:38 AM
To: Apache Directory = Developers List
Subject: Re: [SHARED] Is = there an easy way to compare filters, some with OID and some = without?

 

 

On Wed, Feb 18, 2009 at 10:25 AM, Hammond, Steve <steve.hammond@polycom.com&g= t; wrote:

I am trying to compare 2 filters (ExprNode), it happens to be an and = clause, but that is irrelevant.

 

So my code is if ( filter.equals(groupUnimporte<= /i>d))   // special filter case.

 =

The problem is that when it = gets to this code filter =3D (&(2.5.4.0=3Dgroup)(!(1.2.840.113556.1.4.26=3D-1)))

And groupUnimported=3D = (&(objectClass=3Dgroup)(!(ugpid=3D-1)))

 

I can look at those and know they are equal.  Is = there some normalizer I can run the 2 ExprNodes thru before doing the equals?  = I don't want to do 4 separate equals tests, especially if we start to get = bigger filters that end up as special cases.

You're in luck = Steve. You can use the following visitor implementation to perform normalized = comparisons of filter expressions.  This was specifically written to match for equivalent logical expressions that may have term order variations.

Here take a look:

    http://ahkaek.notlong.com/

This BranchNormalizedVisitor will normalize the order of terms in a = filter branch (OR / AND nodes only) without effecting the logic of the filter. = After doing this the filter can be dumped to a string and compared.

In addition to this you'll want to normalize attributes to OID's which = is easy to do if you have access to the schema.  Just write another visitor = to change the attribute alias names in leaf nodes to their respective OID = value using the lookup method in AttriuteTypeRegistry.

HTH,
Alex

------_=_NextPart_001_01C991E2.75BDF5AB--