Creating a new operator class

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:

  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.

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.

When you use the DBDK to create an operator class, you do not have to create the SQL statements to register the support and strategy functions with the database server because the DBDK automatically generates the necessary scripts. You do, however, need to write the C code that implements the support and strategy functions.

The DBDK does not automatically generate the SQL statement to create an operator class. Instead, you must create custom SQL files from BladeSmith by choosing Edit > Insert > SQL > Files.

For more information about DBDK and BladeSmith, refer to the HCL Informix® DataBlade Developers Kit User's Guide.

For more information on the DataBlade API, refer to the HCL 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.

If you use the DBDK to create the data type that is to be indexed by an R-tree index and specify that the R-tree support and strategy functions be automatically generated, the NOT VARIANT clause is included automatically in the CREATE FUNCTION statement. If, however, you create the support and strategy functions yourself, the function is VARIANT by default.


Copyright© 2019 HCL Technologies Limited