Time Index question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Time Index question

BrunoBB
Hi All,

I having problems when creating a equality index on a Time instance variable.

The following works ok with a index on String:
| stringField stringCol |
 
IndexManager current removeAllIndexes.

stringField := AppFieldStringValue new.
stringField name: 'name';
        originalValue: 'hello';
        setValue: 'hello'.

stringCol := RcIdentityBag new.
stringCol add: stringField.

stringCol createEqualityIndexOn: 'value'
withLastElementClass: String.

(GsQuery fromString:
('each.value  = ', '''hello''') on: stringCol)
queryResult.

"BUT IF I WANT TO DO THE SAME WITH TIME I GET AN ERROR"
"ERROR:
a Time class does not understand  #'_idxBasicCanCompareWithCharacterCollectionInstance:"
| timeField timeCol |

IndexManager current removeAllIndexes.

timeField := AppFieldTimeValue new.
timeField name: 'time';
        originalValue: Time now;
        setValue: Time now.

timeCol := RcIdentityBag new.
timeCol add: timeField.

timeCol createEqualityIndexOn: 'value'
withLastElementClass: Time.

(GsQuery fromString:
('each.value  = ', '''15:00:00''') on: timeCol)
queryResult.

The index is on "value" instance variable of AppFieldTimeValue class.
What are the basic classes to create indexes ? String, Integer, Time, Date, TimeStamp... or what ?

There are SmallInteger indexes in the GS manual at Example 7.12 (page 126)

Any help is appreciated ?

Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

GLASS mailing list
Bruno,

The method #_idxBasicCanCompareWithCharacterCollectionInstance: is
implemented in Object class and the following returns `false`:

   Time _idxBasicCanCompareWithCharacterCollectionInstance: ''

What version of GemStone are you using?

When I run your example (in 3.3 using an Association instead of an
AppFieldTimeValue, I get the following error:

   a ImproperOperation occurred (error 2128),
reason:assocErrBadComparison, The evaluation of a SelectBlock resulted
in an illegal comparison being performed.

because you are trying to compare '15:00:00' to a Time instance:

   (GsQuery fromString: 'each.value  = ''15:00:00''' on: timeCol)
             queryResult

If I change the query to the following, I get the "right" answer:

   timeValue := Time fromString: '15:00:00'.
           (GsQuery fromString: 'each.value  = timeValue' on: timeCol)
             bind: 'timeValue' to: timeValue;
             queryResult

I would like to see the stack details for your `a Time class does not
understand #'_idxBasicCanCompareWithCharacterCollectionInstance:"` error.

Here is the code I am using in 3.3:

| timeField timeCol timeValue |
   IndexManager current removeAllIndexes.
   timeField := 'time' -> Time now.
   timeCol := RcIdentityBag new.
   timeCol add: timeField.
   timeCol createEqualityIndexOn: 'value' withLastElementClass: Time.
   false
     ifTrue: [
       "good"
       timeValue := Time fromString: '15:00:00'.
       (GsQuery fromString: 'each.value  = timeValue' on: timeCol)
         bind: 'timeValue' to: timeValue;
         queryResult ]
     ifFalse: [
       "bad"
       (GsQuery fromString: 'each.value  = ''15:00:00''' on: timeCol)
queryResult ]

Dale

On 02/19/2016 08:58 AM, BrunoBB via Glass wrote:

> Hi All,
>
> I having problems when creating a equality index on a Time instance
> variable.
>
> The following works ok with a index on String:
> | stringField stringCol |
>  
> IndexManager current removeAllIndexes.
>
> stringField := AppFieldStringValue new.
> stringField name: 'name';
> originalValue: 'hello';
> setValue: 'hello'.
>
> stringCol := RcIdentityBag new.
> stringCol add: stringField.
>
> stringCol createEqualityIndexOn: 'value'
> withLastElementClass: String.
>
> (GsQuery fromString:
> ('each.value  = ', '''hello''') on: stringCol)
> queryResult.
>
> "BUT IF I WANT TO DO THE SAME WITH TIME I GET AN ERROR"
> "ERROR:
> a Time class does not understand
> #'_idxBasicCanCompareWithCharacterCollectionInstance:"
> | timeField timeCol |
>
> IndexManager current removeAllIndexes.
>
> timeField := AppFieldTimeValue new.
> timeField name: 'time';
> originalValue: Time now;
> setValue: Time now.
>
> timeCol := RcIdentityBag new.
> timeCol add: timeField.
>
> timeCol createEqualityIndexOn: 'value'
> withLastElementClass: Time.
>
> (GsQuery fromString:
> ('each.value  = ', '''15:00:00''') on: timeCol)
> queryResult.
>
> The index is on "value" instance variable of AppFieldTimeValue class.
> What are the basic classes to create indexes ? String, Integer, Time, Date,
> TimeStamp... or what ?
>
> There are SmallInteger indexes in the GS manual at Example 7.12 (page 126)
>
> Any help is appreciated ?
>
> Regards,
> Bruno
>
>
>
> --
> View this message in context: http://forum.world.st/Time-Index-question-tp4879024.html
> Sent from the GLASS mailing list archive at Nabble.com.
> _______________________________________________
> Glass mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/glass

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

BrunoBB
Dale,

I will check what you are telling to me.

GS version: 3.2.1

Implementors of: _idxBasicCanCompareWithCharacterCollectionInstance:
* CharacterCollection class
* Unicode7 class
* Unicode16 class
* Unicode32 class

It is safe to define:
Object class>>
_idxBasicCanCompareWithCharacterCollectionInstance: aCharacterCollection
^false

Time _idxBasicCanCompareWithCharacterCollectionInstance: ''
"this fail with doesNotUnderstand:"

I will check your answer, thanks very much:

The Stack:
MessageNotUnderstood >> defaultAction @2 line 3
MessageNotUnderstood (AbstractException) >> _signalWith: @5 line 25
MessageNotUnderstood (AbstractException) >> signal @2 line 47
Time class (Object) >> doesNotUnderstand: @9 line 10
Time class (Object) >> _doesNotUnderstand:args:envId:reason: @7 line 12
String (CharacterCollection) >> _idxBasicCanCompareWithClass: @2 line 8
BtreeBasicLeafNode (BtreeNode) >> _basicCanCompare:withClass: @2 line 5
BtreeBasicLeafNode >> _canCompare:withClass: @2 line 5
RangeEqualityIndex >> _canCompareWith: @4 line 8
EqualityIndexQueryEvaluator >> _findAllValuesGreaterThan:andEquals:andLessThan:andEquals:using: @3 line 8
EqualityIndexQueryEvaluator >> findAllValuesEqualTo: @3 line 6
GsPathConstantPredicate >> executeClauseUsing:queryEvaluator: @43 line 31
GsPathConstantPredicate >> executeClauseUsing: @5 line 4
GsPathConstantPredicate >> executeClause @3 line 2
GsPathConstantPredicate (GsQueryFormula) >> execute @2 line 2
GsQuery >> queryResult @18 line 13
Executed Code  @16 line 15
UndefinedObject (GsNMethod class) >> _gsReturnToC @1 line 1

Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

BrunoBB
Dale,

After implementing:
Object class>>
_idxBasicCanCompareWithCharacterCollectionInstance: aCharacterCollection
^false

The error is the one you point out "ImproperOperation".

Again thanks for your answer....

Regards,
Bruno

ImproperOperation (AbstractException) >> _signalWith: @5 line 25
ImproperOperation (AbstractException) >> signal @2 line 47
EqualityIndexQueryEvaluator (Object) >> _error: @13 line 7
EqualityIndexQueryEvaluator >> _findAllValuesGreaterThan:andEquals:andLessThan:andEquals:using: @8 line 9
EqualityIndexQueryEvaluator >> findAllValuesEqualTo: @3 line 6
GsPathConstantPredicate >> executeClauseUsing:queryEvaluator: @43 line 31
GsPathConstantPredicate >> executeClauseUsing: @5 line 4
GsPathConstantPredicate >> executeClause @3 line 2
GsPathConstantPredicate (GsQueryFormula) >> execute @2 line 2
GsQuery >> queryResult @18 line 13
Executed Code  @16 line 15
UndefinedObject (GsNMethod class) >> _gsReturnToC @1 line 1
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

BrunoBB
Dale,

Tested your code in 3.2.1 and is working OK.

Thanks very much....

The only thing is i do not know is why _idxBasicCanCompareWithCharacterCollectionInstance: was not implemented in Object class.
Anyway everything is working as expected now.

Regards,
Bruno

Updated script (just for the record):

| timeField timeCol timeValue |

IndexManager current removeAllIndexes.

timeField := AppFieldTimeValue new.
timeField name: 'time';
        originalValueIsStObject: true;
        originalValue: (Time fromString: '15:00:00');
        setValue: (Time fromString: '15:00:00').

timeCol := RcIdentityBag new.
timeCol add: timeField.

timeCol createEqualityIndexOn: 'value' withLastElementClass: Time.

timeValue := Time fromString: '15:00:00'.

(GsQuery fromString: 'each.value = timeValue' on: timeCol)
bind: 'timeValue' to: timeValue;
queryResult.
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

GLASS mailing list
Yes that is very strange ... it is method that should have been "owned"
by SystemUser, so it shouldn't have been easy to remove it from the
system ... yet it is safe to add it as DataCurator ....

I will bring up a 3.2.1 system and confirm that method is present in the
base system.

Dale

On 02/19/2016 10:27 AM, BrunoBB via Glass wrote:

> Dale,
>
> Tested your code in 3.2.1 and is working OK.
>
> Thanks very much....
>
> The only thing is i do not know is why
> _idxBasicCanCompareWithCharacterCollectionInstance: was not implemented in
> Object class.
> Anyway everything is working as expected now.
>
> Regards,
> Bruno
>
> Updated script (just for the record):
>
> | timeField timeCol timeValue |
>
> IndexManager current removeAllIndexes.
>
> timeField := AppFieldTimeValue new.
> timeField name: 'time';
> originalValueIsStObject: true;
> originalValue: (Time fromString: '15:00:00');
> setValue: (Time fromString: '15:00:00').
>
> timeCol := RcIdentityBag new.
> timeCol add: timeField.
>
> timeCol createEqualityIndexOn: 'value' withLastElementClass: Time.
>
> timeValue := Time fromString: '15:00:00'.
>
> (GsQuery fromString: 'each.value = timeValue' on: timeCol)
> bind: 'timeValue' to: timeValue;
> queryResult.
>
>
>
> --
> View this message in context: http://forum.world.st/Time-Index-question-tp4879024p4879055.html
> Sent from the GLASS mailing list archive at Nabble.com.
> _______________________________________________
> Glass mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/glass

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

GLASS mailing list
Bruno,

This turns out to be an outstanding bug in 3.2.x (that's what I get for
looking at 3.3 in my initial investigation:).

The bug (44429  P3  Similar index incorrect operation, different errors
of different severity) was fixed in 3.3, but no fix was made in 3.2.x
(yet) ...

The bug doesn't impact correct operation, but does come into play when
incorrect operations are attempted involving indexes ---- You also may
need to implement

Object>>_idxBasicCanCompareWithUnicodeInstance: aUnicodeString
      "Returns true if <aUnicodeString> may be inserted into a basic
BtreeNode whose
      #lastElementClass is the receiver (see RangeEqualityIndex
class>>isBasicClass:)."

      ^ false

as this was also part of the fix ....

Dale

On 02/19/2016 11:57 AM, Dale Henrichs wrote:

> Yes that is very strange ... it is method that should have been
> "owned" by SystemUser, so it shouldn't have been easy to remove it
> from the system ... yet it is safe to add it as DataCurator ....
>
> I will bring up a 3.2.1 system and confirm that method is present in
> the base system.
>
> Dale
>
> On 02/19/2016 10:27 AM, BrunoBB via Glass wrote:
>> Dale,
>>
>> Tested your code in 3.2.1 and is working OK.
>>
>> Thanks very much....
>>
>> The only thing is i do not know is why
>> _idxBasicCanCompareWithCharacterCollectionInstance: was not
>> implemented in
>> Object class.
>> Anyway everything is working as expected now.
>>
>> Regards,
>> Bruno
>>
>> Updated script (just for the record):
>>
>> | timeField timeCol timeValue |
>>
>> IndexManager current removeAllIndexes.
>>
>> timeField := AppFieldTimeValue new.
>> timeField name: 'time';
>>     originalValueIsStObject: true;
>>     originalValue: (Time fromString: '15:00:00');
>>     setValue: (Time fromString: '15:00:00').
>>
>> timeCol := RcIdentityBag new.
>> timeCol add: timeField.
>>
>> timeCol createEqualityIndexOn: 'value' withLastElementClass: Time.
>>
>> timeValue := Time fromString: '15:00:00'.
>>
>> (GsQuery fromString: 'each.value = timeValue' on: timeCol)
>> bind: 'timeValue' to: timeValue;
>> queryResult.
>>
>>
>>
>> --
>> View this message in context:
>> http://forum.world.st/Time-Index-question-tp4879024p4879055.html
>> Sent from the GLASS mailing list archive at Nabble.com.
>> _______________________________________________
>> Glass mailing list
>> [hidden email]
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

BrunoBB
Dale,

You were faster than me :)

I just ran a clean (without any of my packages) version of GS 3.2.1 and the methods are missing.

Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: Time Index question

GLASS mailing list
Haha .... the bugfix for this ought to show up in 3.2.13 and is already
in 3.3 ...

Thanks for the report!

Dale

On 02/19/2016 12:18 PM, BrunoBB via Glass wrote:

> Dale,
>
> You were faster than me :)
>
> I just ran a clean (without any of my packages) version of GS 3.2.1 and the
> methods are missing.
>
> Regards,
> Bruno
>
>
>
> --
> View this message in context: http://forum.world.st/Time-Index-question-tp4879024p4879073.html
> Sent from the GLASS mailing list archive at Nabble.com.
> _______________________________________________
> Glass mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/glass

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass