The ObjectLength function

The R-tree secondary access method uses the ObjectLength function to determine the maximum size, in bytes, of the objects stored in the column that is being indexed with an R-tree index.

The ObjectLength support function is optional. If you create it and specify it in the operator class with the other optional support functions, the R-tree secondary access method uses a fast bulk-loading algorithm to initially create an R-tree index. If you have not specified this function in the operator class, then the access method uses a slower method to create R-tree indexes.

The SQL signature of the ObjectLength support function must be:
ObjectLength (UDT, POINTER) RETURNS INTEGER

UDT refers to user-defined type, or the data type you want to index with the R-tree access method.

The sample C signature of the ObjectLength function is:
mi_integer ObjectLength(mi_lvarchar *object, mi_integer *obj_max_length)

The first parameter of the ObjectLength function contains the name of the data type to be indexed; it does not contain a row value. For example, if the data type to be indexed is MyPoint, the parameter contains the string MyPoint.

Write the ObjectLength function to return, in the second parameter, the maximum possible size, in bytes, of the objects in the column to be indexed.

The return value of the ObjectLength function is not used by the R-tree access method. The ObjectLength function should call the mi_db_error_raise() DataBlade® API function to return errors.

For sample C code of the ObjectLength function, see ObjectLength support function. C code uses the DataBlade API to interact with the database server.