Wednesday, July 11, 2007

how to exhaust your UVAs without knowing it

Unique Value Allocators (UVAs) in Smallworld are special objects that return a unique integer value for system IDs only once. Theoretically you could exhaust your UVA bucket at some point and then you will not be able to insert any more RWOs, geometries, links, nodes and other system objects.

There are a number of ways to exhaust your UVAs but one that came to my attention recently is the method :copy_transform() on various geometry classes. I have used this method in the past for exporting geometries to some other file format. What was strange at the time was that when I used this method I received a "database not writable" error. That raised some red flags in my mind: why does the database need to be writable if all I intend to do is read data from it and export it to another file format?

It turns out in that case that I was using :copy_transform() to convert the coordinates of geometries from one coordinate system to another. Unbeknown to me, the :copy_transform() method actually makes a copy of your geometry before transforming it. So you are left with two copies of the same geometry in the database after the transform. And creating a copy of the geometry uses UVAs (which cannot be recovered) and involves more system resources than you would likely need for your intended purpose -- simply to transform the coordinates of a geometry from one coordinate system to another.

I am writing all this because we have come across a situation where an installation used export code from another vendor that apparently makes frequent use of the :copy_transform() method to export geometry data into a 3rd party format. Recently that installation's main UVA was exhausted. There is nothing wrong with transforming your coordinates before exporting to a 3rd party but there are simpler ways of doing transforms using !current_coordinate_system! that do not gobble up UVA resources (maybe I will post about that some day).

I would recommend that you run the following command at the Magik prompt:

MagikSF> print_users_of(:copy_transform|()|)
$

The output of this procedure will list all methods that call :copy_transform(). Scan the list and if any of the method names (or classes that they are written on) look as though they are not core Smallworld methods/classes, please confirm that that code cannot be done some other way without using up your precious UVAs.


(There are other ways to exhaust your UVAs prematurely, but I wanted to focus on this one approach today)

No comments: