[Glass] Time Index question

Dale Henrichs via Glass glass at lists.gemtalksystems.com
Fri Feb 19 10:09:46 PST 2016


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
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass



More information about the Glass mailing list