This can't be right, I must've meant (rebuild 29 'article '+ArFeLink) ?


On Thu, Jan 21, 2010 at 4:49 PM, Henrik Sarvell <hsarv...@gmail.com> wrote:

> After some discussion on IRC I did the following:
>
> (rebuild 29 '+ArFeLink 'article)
>
> Where 29 is the number of the database file in question and 'article is the
> relation. It had (+Ref +Link), it now has (+Aux +Ref +Link).
>
> So far I haven't noticed any problems.
>
>
>
> On Wed, Jan 20, 2010 at 8:13 AM, Alexander Burger <a...@software-lab.de>wrote:
>
>> Hi Henrik,
>>
>> > and it was on IRC so better get it out here. What exactly happens if I
>> for
>> > instance add an +Aux relation, will the DB engine recognize that it's
>> new
>> > and create the index to include all concerned objects, or will it simply
>>
>> When the DB model (the "er.l" file) is changed, it is not automatically
>> detected at runtime. This would be difficult, as it might require a scan
>> of the whole database. Also, a program is allowed to create arbitrary
>> data, possibly outside the DB model, so such an automatism would be
>> dangerous.
>>
>> The programmer must understand the implications of a change, and run an
>> explicit rebuild-script. Adding or changing an index (like adding an
>> +Aux relation) is one of the most typical cases.
>>
>>
>> > come in to effect on all objects created from now on or will it corrupt
>> the
>> > DB? If I recall correctly it will simply work from now on but existing
>> > objects won't be included in the index.
>>
>> Yes. The DB is not really corrupted in such a case, but the affected
>> objects may not be found at searches.
>>
>>
>> > And if I recall correctly I believe there were also some tools to
>> rebuild in
>> > situations like this or?
>>
>> 'rebuild' (in "lib/too.l") can be used for that.
>>
>> Sometimes, such modifications can be rather complex, and involve changes
>> in the structures or types of objects. I strongly recommend to test it
>> first on a local copy of the database.
>>
>> It is tricky if not only an index, but the type of indexed data changes.
>> For example, I had the case last week that the "Land" property of
>> several object classes changed from a plain string
>>
>>   (+Ref +String)
>>
>> to an entity
>>
>>   (+Ref +Link) NIL (+Land))
>>
>> Then simply changing the string in all objects to a '+Link' does not
>> work, because the new index has a different structure. Therefore,
>> removing the old string must happen in the old model, while setting the
>> +Link to the land object must happen in the new model. I achieved this
>> by switching the class of that relation daemon with 'bind' during each
>> change:
>>
>>   (for (This ...)   # Iterate all involved objects
>>      (let Str (: lnd)  # Keep the string value
>>         (bind  # Temporarily set old relation classes
>>            (list
>>               (cons (get '+Cls1 'lnd) '(+Need +Sn +Idx +String))
>>               (cons (get '+Cls2 'lnd) '(+Ref +String))
>>               ... )
>>            (put> This 'lnd NIL) )   # Clear old value and index
>>         (put> This 'lnd  # Set new (entity) value and build index
>>            (request '(+Land) ... Str ..) ) ) )
>>
>> This is just an example how complex such changes can be. But, on the
>> other hand, there is almost no limit on what can be done.
>>
>> Cheers,
>> - Alex
>> --
>> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
>>
>
>

Reply via email to