Updating an index

Chris Muller asqueaker at gmail.com
Thu Mar 13 23:44:21 UTC 2008


> The question is: is there a way to force  an index to update its keys? or

Norberto, please check the Magma documentation page, it tells you how
to update index values.

> Suposing an index is not properly updated or is not updated at all, can I
> force this updating?

Not easily.  If you didn't correctly notify Magma of index key changes
and the index is now out of date, the best thing to do would be to
delete and re-add the object  so it will be indexed at the correct
keys.

> You would demand: why do you need this? Perhaps something is wrong in your
> objects, so the index is not updated.

Uhhh... No, I would demand nothing of the sort.

> No, the problem is that this index doen't match with an instance variable of
> the objects in the collection. It's a key generated when other condiciones
> changes, produced by a message, not an instance vairable.
>  I suposse that magma doesn't update the indec because there's no changes
> in  variables. Am I wright?

No, that is wrong.  You may be thinking of GemStone, which indexes the
values of instance-variables.  Magma indexes the return value of the
method denoted by the indexed attribute.  Changes in variables have no
bearing on updates, you have to send #noteOldKeysFor:.

> But you would insist: why do you need this? A "calculated" index? Why don't
> you use a variable?
>
> I have this situation: there are several methods for testing the objects,
> that answer a boolean. I need to filter the collections regarding wich
> objects answer true, and wich others answer false. I need something like a
> filter, but I didn't find it.  The way I found to solve this problem is to
> generate a single key that uses the boolens as they were bits, so with an
> integer index, I cant retrieve the objetos with several filterings. But the
> index is not updated!  The only way is to remove and recreate it.

You never want to use an index that can only have two values.
Instead, you would simply have two collections, one for the true's,
the other for the falses..

 - Chris


More information about the Magma mailing list