You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2011/06/15 13:53:21 UTC

Is this intended, or should we consider that is a bug ?

Hi,

I'm wondering if the following code snippet is just a bug, or if this 
was intended :

     public PresenceEvaluator( PresenceNode node, Store<Entry, ID> db, 
SchemaManager schemaManager )
         throws Exception
     {
         this.db = db;
         this.node = node;
         this.schemaManager = schemaManager;
         this.attributeType = node.getAttributeType();

         if ( db.hasUserIndexOn( attributeType ) )
         {
             idx = db.getPresenceIndex();
         }
         else
         {
             idx = null;
         }
     }

In my case, the AttributeType is ObjectClass, which is a System index. I 
find it extremely doubtful that we want to set idx to null in this very 
case.

However, this is a part of the code I'm not really familiar with, so if 
any has some clue, I'd appreciate it.

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: Is this intended, or should we consider that is a bug ?

Posted by Alex Karasulu <ak...@apache.org>.
On Wed, Jun 15, 2011 at 3:07 PM, Stefan Seelmann <se...@apache.org> wrote:
> On Wed, Jun 15, 2011 at 1:53 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
>> Hi,
>>
>> I'm wondering if the following code snippet is just a bug, or if this was
>> intended :
>>
>>    public PresenceEvaluator( PresenceNode node, Store<Entry, ID> db,
>> SchemaManager schemaManager )
>>        throws Exception
>>    {
>>        this.db = db;
>>        this.node = node;
>>        this.schemaManager = schemaManager;
>>        this.attributeType = node.getAttributeType();
>>
>>        if ( db.hasUserIndexOn( attributeType ) )
>>        {
>>            idx = db.getPresenceIndex();
>>        }
>>        else
>>        {
>>            idx = null;
>>        }
>>    }
>>
>> In my case, the AttributeType is ObjectClass, which is a System index. I
>> find it extremely doubtful that we want to set idx to null in this very
>> case.
>
> AFAIK we only add user attributes to the precence index. System
> attributes (objectClass, entryUUID, entryCSN) are not added to the
> precense index because they are always present in an entry so it would
> be a waste of space to add them to the presence index. Instead in
> another part of the PresenceEvaluator we check if the index is a
> system index and return true.

Yep and to add to this we're not including top in the objectClass
index itself. Yes this code needs to be updated for all these new
special cases that resulted from adding these new system indices.

Regards,
Alex

Re: Is this intended, or should we consider that is a bug ?

Posted by Stefan Seelmann <se...@apache.org>.
On Wed, Jun 15, 2011 at 2:07 PM, Stefan Seelmann <se...@apache.org> wrote:
> On Wed, Jun 15, 2011 at 1:53 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
>> Hi,
>>
>> I'm wondering if the following code snippet is just a bug, or if this was
>> intended :
>>
>>    public PresenceEvaluator( PresenceNode node, Store<Entry, ID> db,
>> SchemaManager schemaManager )
>>        throws Exception
>>    {
>>        this.db = db;
>>        this.node = node;
>>        this.schemaManager = schemaManager;
>>        this.attributeType = node.getAttributeType();
>>
>>        if ( db.hasUserIndexOn( attributeType ) )
>>        {
>>            idx = db.getPresenceIndex();
>>        }
>>        else
>>        {
>>            idx = null;
>>        }
>>    }
>>
>> In my case, the AttributeType is ObjectClass, which is a System index. I
>> find it extremely doubtful that we want to set idx to null in this very
>> case.
>
> AFAIK we only add user attributes to the precence index. System
> attributes (objectClass, entryUUID, entryCSN) are not added to the
> precense index because they are always present in an entry so it would
> be a waste of space to add them to the presence index. Instead in
> another part of the PresenceEvaluator we check if the index is a
> system index and return true.
>
> However I see that this is confusing because the logic is splitted
> between different classes (Store, PresenceEvaluator, PrecenseCursor).

Damn ugly word, I mean "Presence" of course ;-)

Re: Is this intended, or should we consider that is a bug ?

Posted by Emmanuel Lécharny <el...@apache.org>.
On 6/15/11 2:07 PM, Stefan Seelmann wrote:
> On Wed, Jun 15, 2011 at 1:53 PM, Emmanuel Lecharny<el...@gmail.com>  wrote:
>> Hi,
>>
>> I'm wondering if the following code snippet is just a bug, or if this was
>> intended :
>>
>>     public PresenceEvaluator( PresenceNode node, Store<Entry, ID>  db,
>> SchemaManager schemaManager )
>>         throws Exception
>>     {
>>         this.db = db;
>>         this.node = node;
>>         this.schemaManager = schemaManager;
>>         this.attributeType = node.getAttributeType();
>>
>>         if ( db.hasUserIndexOn( attributeType ) )
>>         {
>>             idx = db.getPresenceIndex();
>>         }
>>         else
>>         {
>>             idx = null;
>>         }
>>     }
>>
>> In my case, the AttributeType is ObjectClass, which is a System index. I
>> find it extremely doubtful that we want to set idx to null in this very
>> case.
> AFAIK we only add user attributes to the precence index. System
> attributes (objectClass, entryUUID, entryCSN) are not added to the
> precense index because they are always present in an entry so it would
> be a waste of space to add them to the presence index. Instead in
> another part of the PresenceEvaluator we check if the index is a
> system index and return true.

Stefan, you are absolutely right. The following code demonstrate it :

     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         if ( db.hasSystemIndexOn( attributeType ) )
         {
             // we don't maintain a presence index for objectClass, 
entryUUID, and entryCSN
             // however as every entry has such an attribute this 
evaluator always evaluates to true
             return true;
         }

Thanks a lot !

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: Is this intended, or should we consider that is a bug ?

Posted by Stefan Seelmann <se...@apache.org>.
On Wed, Jun 15, 2011 at 1:53 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
> Hi,
>
> I'm wondering if the following code snippet is just a bug, or if this was
> intended :
>
>    public PresenceEvaluator( PresenceNode node, Store<Entry, ID> db,
> SchemaManager schemaManager )
>        throws Exception
>    {
>        this.db = db;
>        this.node = node;
>        this.schemaManager = schemaManager;
>        this.attributeType = node.getAttributeType();
>
>        if ( db.hasUserIndexOn( attributeType ) )
>        {
>            idx = db.getPresenceIndex();
>        }
>        else
>        {
>            idx = null;
>        }
>    }
>
> In my case, the AttributeType is ObjectClass, which is a System index. I
> find it extremely doubtful that we want to set idx to null in this very
> case.

AFAIK we only add user attributes to the precence index. System
attributes (objectClass, entryUUID, entryCSN) are not added to the
precense index because they are always present in an entry so it would
be a waste of space to add them to the presence index. Instead in
another part of the PresenceEvaluator we check if the index is a
system index and return true.

However I see that this is confusing because the logic is splitted
between different classes (Store, PresenceEvaluator, PrecenseCursor).

HTH,
Stefan

Re: Is this intended, or should we consider that is a bug ?

Posted by Emmanuel Lécharny <el...@apache.org>.
On 6/15/11 2:09 PM, Alex Karasulu wrote:
> On Wed, Jun 15, 2011 at 3:04 PM, Emmanuel Lécharny<el...@apache.org>  wrote:
>> On 6/15/11 2:01 PM, Alex Karasulu wrote:
>>> On Wed, Jun 15, 2011 at 2:53 PM, Emmanuel Lecharny<el...@gmail.com>
>>>   wrote:
>>>> Hi,
>>>>
>>>> I'm wondering if the following code snippet is just a bug, or if this was
>>>> intended :
>>>>
>>>>     public PresenceEvaluator( PresenceNode node, Store<Entry, ID>    db,
>>>> SchemaManager schemaManager )
>>>>         throws Exception
>>>>     {
>>>>         this.db = db;
>>>>         this.node = node;
>>>>         this.schemaManager = schemaManager;
>>>>         this.attributeType = node.getAttributeType();
>>>>
>>>>         if ( db.hasUserIndexOn( attributeType ) )
>>>>         {
>>>>             idx = db.getPresenceIndex();
>>>>         }
>>>>         else
>>>>         {
>>>>             idx = null;
>>>>         }
>>>>     }
>>>>
>>>> In my case, the AttributeType is ObjectClass, which is a System index. I
>>>> find it extremely doubtful that we want to set idx to null in this very
>>>> case.
>>> This is valid code for the general case when you don't know what the
>>> attributeType is. If the attributeType is not indexed then we cannot
>>> use the presence index for =* evaluation. In the case of objectClass
>>> this does seem moot but this code operates on all cases so it's valid.
>>>
>>> Does this explanation make sense?
>> Yes, but the ObjectClass AT *is* indexed, so why don't we set the idx to
>> point on the ObjectClass index ? This is what I don't understand.
>>
>> I was expecting such code :
>>
>>
>>
>>        if ( db.hasUserIndexOn( attributeType ) || ( db.hasSystemIndexOn(
>> attributeType ) )
>>        {
>>            idx = db.getPresenceIndex();
>>        }
>>        else
>>        {
>>            idx = null;
>>        }
> OK I see what you mean. ObjectClass is a system index. Yes you are
> right here. We changed this and did not update this code. I did not
> understand this situation in my last post - my apologies.

Interesting debugging session :)

     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         if ( db.hasSystemIndexOn( attributeType ) )
         {
             // we don't maintain a presence index for objectClass, 
entryUUID, and entryCSN
             // however as every entry has such an attribute this 
evaluator always evaluates to true
             return true;
         }


Seems like the idx can be null in this very case, as it's handled 
elsewhere in the code (here, attributeType is ObjectClass).

So my initial mail is now answered : it's intended.

Thanks guys !

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: Is this intended, or should we consider that is a bug ?

Posted by Alex Karasulu <ak...@apache.org>.
On Wed, Jun 15, 2011 at 3:04 PM, Emmanuel Lécharny <el...@apache.org> wrote:
> On 6/15/11 2:01 PM, Alex Karasulu wrote:
>>
>> On Wed, Jun 15, 2011 at 2:53 PM, Emmanuel Lecharny<el...@gmail.com>
>>  wrote:
>>>
>>> Hi,
>>>
>>> I'm wondering if the following code snippet is just a bug, or if this was
>>> intended :
>>>
>>>    public PresenceEvaluator( PresenceNode node, Store<Entry, ID>  db,
>>> SchemaManager schemaManager )
>>>        throws Exception
>>>    {
>>>        this.db = db;
>>>        this.node = node;
>>>        this.schemaManager = schemaManager;
>>>        this.attributeType = node.getAttributeType();
>>>
>>>        if ( db.hasUserIndexOn( attributeType ) )
>>>        {
>>>            idx = db.getPresenceIndex();
>>>        }
>>>        else
>>>        {
>>>            idx = null;
>>>        }
>>>    }
>>>
>>> In my case, the AttributeType is ObjectClass, which is a System index. I
>>> find it extremely doubtful that we want to set idx to null in this very
>>> case.
>>
>> This is valid code for the general case when you don't know what the
>> attributeType is. If the attributeType is not indexed then we cannot
>> use the presence index for =* evaluation. In the case of objectClass
>> this does seem moot but this code operates on all cases so it's valid.
>>
>> Does this explanation make sense?
>
> Yes, but the ObjectClass AT *is* indexed, so why don't we set the idx to
> point on the ObjectClass index ? This is what I don't understand.
>
> I was expecting such code :
>
>
>
>       if ( db.hasUserIndexOn( attributeType ) || ( db.hasSystemIndexOn(
> attributeType ) )
>       {
>           idx = db.getPresenceIndex();
>       }
>       else
>       {
>           idx = null;
>       }

OK I see what you mean. ObjectClass is a system index. Yes you are
right here. We changed this and did not update this code. I did not
understand this situation in my last post - my apologies.

Great catch!

Alex

Re: Is this intended, or should we consider that is a bug ?

Posted by Emmanuel Lécharny <el...@apache.org>.
On 6/15/11 2:01 PM, Alex Karasulu wrote:
> On Wed, Jun 15, 2011 at 2:53 PM, Emmanuel Lecharny<el...@gmail.com>  wrote:
>> Hi,
>>
>> I'm wondering if the following code snippet is just a bug, or if this was
>> intended :
>>
>>     public PresenceEvaluator( PresenceNode node, Store<Entry, ID>  db,
>> SchemaManager schemaManager )
>>         throws Exception
>>     {
>>         this.db = db;
>>         this.node = node;
>>         this.schemaManager = schemaManager;
>>         this.attributeType = node.getAttributeType();
>>
>>         if ( db.hasUserIndexOn( attributeType ) )
>>         {
>>             idx = db.getPresenceIndex();
>>         }
>>         else
>>         {
>>             idx = null;
>>         }
>>     }
>>
>> In my case, the AttributeType is ObjectClass, which is a System index. I
>> find it extremely doubtful that we want to set idx to null in this very
>> case.
> This is valid code for the general case when you don't know what the
> attributeType is. If the attributeType is not indexed then we cannot
> use the presence index for =* evaluation. In the case of objectClass
> this does seem moot but this code operates on all cases so it's valid.
>
> Does this explanation make sense?
Yes, but the ObjectClass AT *is* indexed, so why don't we set the idx to 
point on the ObjectClass index ? This is what I don't understand.

I was expecting such code :



        if ( db.hasUserIndexOn( attributeType ) || ( db.hasSystemIndexOn( attributeType ) )
        {
            idx = db.getPresenceIndex();
        }
        else
        {
            idx = null;
        }


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: Is this intended, or should we consider that is a bug ?

Posted by Alex Karasulu <ak...@apache.org>.
On Wed, Jun 15, 2011 at 2:53 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
> Hi,
>
> I'm wondering if the following code snippet is just a bug, or if this was
> intended :
>
>    public PresenceEvaluator( PresenceNode node, Store<Entry, ID> db,
> SchemaManager schemaManager )
>        throws Exception
>    {
>        this.db = db;
>        this.node = node;
>        this.schemaManager = schemaManager;
>        this.attributeType = node.getAttributeType();
>
>        if ( db.hasUserIndexOn( attributeType ) )
>        {
>            idx = db.getPresenceIndex();
>        }
>        else
>        {
>            idx = null;
>        }
>    }
>
> In my case, the AttributeType is ObjectClass, which is a System index. I
> find it extremely doubtful that we want to set idx to null in this very
> case.

This is valid code for the general case when you don't know what the
attributeType is. If the attributeType is not indexed then we cannot
use the presence index for =* evaluation. In the case of objectClass
this does seem moot but this code operates on all cases so it's valid.

Does this explanation make sense?

Regards,
Alex