The SetUnion function

The R-tree secondary access method uses the SetUnion function to determine the union of all the elements in an array of objects of the data type of the column that is being indexed with an R-tree index.

The SetUnion 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 SetUnion support function must be:
SetUnion (UDT, INTEGER, 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 SetUnion function is:
mi_integer SetUnion (mi_lvarchar *objects, mi_integer array_size, 
                     void *UnionObject)

Write the SetUnion function to store an array of mi_lvarchar pointers in the data portion of the first parameter. Each mi_lvarchar pointer points to objects in the table for which the R-tree access method needs to compute the union. Each of the objects is either a data object or a bounding box.

The second parameter is the number of elements in the array.

The third output parameter is a single object that contains the union of all the objects in the input array of the first parameter. The R-tree secondary access method uses the Union support function to automatically allocate enough space for the output value.

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

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