Creating a new operator class

About this task

Although the R-tree access method includes a default operator class that is called rtree_ops, you must create a new operator class when you are developing a DataBlade® module that uses the R-tree access method.

The rtree_ops operator class is provided primarily for generic R-tree testing and as an example of how to create a new operator class. The rtree_ops operator class includes only the four required strategy functions: Overlap, Equal, Contains, and Within. If you want to create more than these four strategy functions, you must create your own operator class.

The rtree_ops operator class also restricts the number of support functions to the three required ones: Union, Size, and Inter. Because bottom-up building of R-tree indexes requires that you also create the SFCbits, ObjectLength, SFCvalue, and SetUnion functions, the rtree_ops operator class does not support bottom-up building.

To create a new operator class:

Procedure

  1. Create the required support functions.

    This step includes writing the C code using the DataBlade API to implement the required support functions and defining the SQL statements to register the function with the database server.

    This step is described in Support functions.

  2. Create the required strategy functions.
    Similar to support functions, this step includes writing the C code using the DataBlade API to implement the required strategy functions and defining the SQL statements to register the function with the database server.

    This step is described in Strategy functions.

  3. Create the operator class by creating custom SQL to register the operator class with the database server.

    This step is described in Syntax for creating a new operator class.

Results

Each access method has different requirements for the support and strategy functions. The following topics describe the support and strategy functions that the R-tree access method requires. These topics also provide examples of how to create them.

For more information on the DataBlade API, refer to the Informix® DataBlade API Programmer's Guide.
Important: The R-tree access method requires that all support and strategy functions be nonvariant or that they always return the same results when run with the same arguments. To define a nonvariant function, specify NOT VARIANT in the WITH clause of the CREATE FUNCTION statement.