Home

DataBlade Module Example Descriptions

This section describes the example DataBlade modules provided with the DataBlade Developers Kit.

Topic-to-Example Table

The following table lists topics, in alphabetical order, covered by the example DataBlade modules provided with the DataBlade Developers Kit.

Main Topic Subtopic DataBlade Module
Accessor functions ActiveX value objects

Color

Multirep

ActiveX Client value objects Color
C++ Client program UDTExporter
  ActiveX value objects Color
Casts Numeric to text Strings
Client Using ESQL/C UDTExporter
  Using C++ UDTExporter
  Using ActiveX value objects Color
Collection data types Returning a collection with a user-defined routine DataBladeAPI

TopK Terms

Parts Explosion

  Retrieving through ESQL/C UDTExporter
  Argument in a user-defined routine TopK Terms
DataBlade API User-defined routines for the server DataBladeAPI
ESQL/C Client program UDTExporter
GLS Using GLS routines Strings
Intel MMX Technology Matching strings MMX String Search
  Matrix multiplication MMX Matrix
  Image manipulation MMX Image
Large object data types Multirepresentational data types

Multirep

Strings

MMX Image

  Support functions (Assign, Destroy, LOhandles) Multirep
Multirepresentational data types Variable-length opaque data type Multirep
Opaque data types Variable length Multirep
  Multirepresentational Multirep
  Floating-point array Multirep
  Integer array FuzzyMatch
  Compressed string Strings
  Retrieving through ESQL/C UDTExporter
  Coordinate points Circle
  With an opaque data type member Circle
  Image with MMX MMX Image
  With user-defined statistics Box
  Displaying as ActiveX value objects Color
Row data types Creating a typed table FuzzyMatch
  Retrieving through ESQL/C UDTExporter
Secondary access methods User-defined Strings
Support functions Large objects (Assign, Destroy, LOhandles) Multirep
  Custom Input function FuzzyMatch

Strings

  ActiveX value objects Color
  Statistics functions Box
  Custom Output function Strings
User-defined routines Matching strings with MMX MMX String Search
  Matrix multiplication with MMX MMX Matrix
  Manipulating opaque data type members Multirep
  Returning a set DataBladeAPI
  Arithmetic Business

Matrix Math

  Iterator TopK Terms
  Containment Circle
  Selectivity Box
  Matching numbers FuzzyMatch

Example Descriptions

The following example DataBlade modules are provided in the dbdk\examples directory:

Most of these examples have a BladeSmith project file (.ibs) and source code, SQL registration scripts for use with BladeManager, simple installation files for use with BladePack, and functional tests.

Compiled binaries for the examples are not included and must be rebuilt using the source files.

To set up example DataBlade modules, read the readme.txt file in the %INFORMIXDIR%\dbdk\examples directory.

Box DataBlade Module

The Box DataBlade module illustrates how to use user-defined statistics and selectivity with an opaque data type.

This example requires Informix Dynamic Server 2000, Version 9.2.

The Box DataBlade module contains the following objects:

  • The Box opaque data type, which has two members: Height and Width.
  • The BoxArea() user-defined function, which calculates the area of the Box data type.
  • Support routines for the Box data type, including B-tree indexing comparison functions
  • A selectivity function corresponding to each B-tree indexing comparison function
  • Statistics support functions: BoxStatCollect(), BoxStatPrint(), BoxSetMinValue(), BoxSetMaxValue(), and BoxSetHistogram()

The box.dsw file in the %INFORMIXDIR%\dbdk\examples\types\dapi\Statistics\Box\src directory is the Visual C++ workspace file for this DataBlade module.

Business DataBlade Module

The Business DataBlade module illustrates how to perform arithmetic calculations with the following user-defined functions:

  • ExmAmortize. Applies compound interest to loans that are to be paid off in installments.
  • ExmFV. Calculates the value of payments after a given time when compounded at a given interest rate.
  • ExmPV. Calculates the value today of future payments discounted at the appropriate discount rate.

The business.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\dapi\businessmat\src directory is the Visual C++ workspace file for this DataBlade module.

Circle DataBlade Module

The Circle DataBlade module illustrates how to represent two-dimensional coordinates and circles with two opaque types (Pnt and Circ). The Circ data type contains the Pnt data type as one of its members. The DataBlade module provides the Contains() function for calculating the distance between two points and the Distance() function for testing whether a circle contains a given point.

The circle.dsw file in the %INFORMIXDIR%\dbdk\examples\types\dapi\circle\src directory is the Visual C++ workspace file for this DataBlade module.

Color DataBlade Module

The Color DataBlade module illustrates how to encapsulate an opaque data type as an ActiveX value object. It consists of a server project and a client project. The server project defines the Color opaque data type, its support routines, and its accessor methods for execution on the server. The client project provides the code that allows Microsoft Visual Basic to instantiate the server opaque data type as a client-side ActiveX value object; it also provides the ActiveX custom methods and interfaces with which Visual Basic and the client application developer can access the ActiveX value object.

The client program connects to an Informix database table that contains a Color data type column, retrieves a row from that table, and then makes use of the ActiveX client project to visualize (display) the data as a color in Visual Basic.

The Color data type represents standard RGB color codes. It has three members: one each for red, green, and blue.

The readme.txt file in the %INFORMIXDIR%\dbdk\examples\Types\ActiveX\AxColorDemo directory describes:

  • how to create a database containing a table with a Color data type column and how to populate the table with sample data.
  • how to connect to the database server with Visual Basic, using Microsoft RDBC and ODBC.
  • how to create a reference to the Color Project and display the ActiveX value objects for the Color data type in Visual Basic.

The axcolordemo.dsw file in the %INFORMIXDIR%\dbdk\examples\types\activex\axcolordemo\src is the Visual C++ workspace file for this DataBlade module.

DataBladeAPI DataBlade Module

The DataBladeAPI DataBlade module illustrates how to use DataBlade API calls and query processing from within a server user-defined routine. It queries for a column in a table and returns the values as a set.

The DataBladeAPI DataBlade module provides the CIter function and a table.

The databladeapi.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\dap\querydata\src is the Visual C++ workspace file for this DataBlade module.

For more information, read the readme.txt file in the %INFORMIXDIR\dbdk\examples\Routines\dapi\QueryData directory.

FuzzyMatch DataBlade Module

The FuzzyMatch DataBlade module illustrates how to:

  • use row types.
  • write a custom Input support routine.
  • create an opaque data type.
  • use SQL for custom data matching.

The FuzzyMatch DataBlade module was designed for a clothing manufacturer that must store information about the clothing it manufactures and retrieve that information based on color.

The table holding the clothing data is a typed table based on a row type called ClothingType. The ClothingType row type includes an opaque type called ColorType, which holds color information. Custom handling of a color description is performed by the Input routine ColorTypeInput. This routine is based on the assumption that a color description is supplied as a number or a name. The number is an RGB color triplet, with each color appearing in the range 0 through 255. If, while reading the color description, ColorTypeInput detects a leading character rather than a digit, it looks up the name in an external file, called color.map, and uses the associated numeric color value.

To locate data based on color, the FuzzyMatch() function checks to see if two colors are in close proximity by computing the distance between them using a Euclidean metric on the RGB color values. The value is normalized and examined to see if it is less than the value 0-1, as specified by the SQL user. If so, a match is made, and the clothing data is displayed.

The fuzzymatch.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\dapi\fuzzymatch\src directory is the Visual C++ workspace file for this DataBlade module.

Matrix DataBlade Module

The Matrix DataBlade module illustrates how to store and retrieve two-dimensional matrixes, as opaque data types, to and from the database. In addition, it provides user-defined routines that perform arithmetic operations between matrixes of compatible dimensions.

The matrix.dsw file in the %INFORMIXDIR%\dbdk\examples\types\dapi\matrix\src directory is the Visual C++ workspace file for this DataBlade module.

MMX Image DataBlade Module

The MMX Image DataBlade module illustrates how to use an opaque data type to store Windows bitmap images and using user-defined functions to enlarge and reduce them. On computers with Intel MMX processors, these functions use MMX instructions to rescale the images. This example is for Windows NT only.

The mmxi mage.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\mmx\imagescaling\src directory is the Visual C++ workspace file for this DataBlade module.

MMX Matrix DataBlade Module

The MMX Matrix DataBlade module illustrates how to use MMX technologies with a user-defined function from within a DataBlade module to multiply a matrix by a vector to produce another vector. The VxMmx() function uses MMX code to multiply a matrix and a vector to produce another vector.

The mmxmatrix.dsw file in the %INFORMIXDIR%\dbdk\examples\types\mmx\matrix\src directory is the Visual C++ workspace file for this DataBlade module.

MMX String Search DataBlade Module

The MMX String Search DataBlade module illustrates how to use MMX technologies with a user-defined function from within a DataBlade module to test for the presence of one string within another. The strstrmmx() function uses MMX assembly code to match the two strings.

The mmxstring.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\mmx\strings\src\mmxstring directory is the Visual C++ workspace file for this DataBlade module.

Multirep DataBlade Module

The Multirep DataBlade module illustrates how to use multirepresentational data, which is stored in different ways based on its size. This DataBlade module uses an sbspace to store data too large to fit in a database table row.

IMPORTANT: You cannot currently create this DataBlade module using BladeSmith; for information on how to install it, read the readme.html file in the %INFORMIXDIR%\dbdk\examples\Types\dap\MultirepLO directory.

This DataBlade module creates a variable-length opaque data type, MyUdt, containing an internal array of double-precision floating-point values, support functions for MyUdt, and user-defined routines.

These functions are provided:

  • Text input (MyUdtIn) and output (MyUdtOut) for inserting and displaying data in a table
  • Large-object support functions: Assign(), Destroy(), and LOhandles()
  • Two accessor functions to obtain the number of elements in the floating-point array (NumElements) and the value of an individual element (Element)
  • Two modifier functions to append an element to an array (AppendElement()) and change the value of an existing element (ReplaceElement())

The myblade.c file in the %INFORMIXDIR%\dbdk\examples\types\dapi\multireplo directory contains the source code for the MyUdt data type support routines and the user-defined routines.

Parts Explosion DataBlade Module

The Parts Explosion DataBlade module illustrates how to use a simple solution to a parts explosion problem, which finds all dependent child objects for a given parent object. For example, you could find all parts that must be ordered to build the engine of a particular model of automobile.

The assumption for this module is that all objects (parts) are stored in one table. This table has at least two columns:

  • A key column, unique for every object in the table
  • A pointer column describing the "is part of" relationship to other objects in the table

This implementation requires that both the key column and the pointer column be of type INTEGER.

Typically, the table also has a description of the object, its price, and so on. This parts explosion solution is limited in that it is based on the assumption that an object can be the child of only one parent.

This example DataBlade module demonstrates the use of SQL statements within a DataBlade module, how to return a set of results, and the use of the MI_FPARAM structure to return multiple rows. The results of the parts explosion are stored in a linked list in memory allocated by the function before they are returned to the caller.

The parts.dsw file in the is the %INFORMIXDIR%\dbdk\examples\routines\dapi\partsexplode\src directory is the Visual C++ workspace file for this DataBlade module.

Strings DataBlade Module

The Strings DataBlade module illustrates how to use GLS support in user-defined routines that manipulate character strings. This DataBlade module also illustrates how to create custom Input and Output support functions for the CompressedStr data type, an opaque data type containing compressed character data. These functions compress data as it is written to the server and uncompress it as it is written out using Huffman encoding.

The Strings DataBlade module has a cast to convert numeric values to a character string: for example, the number 117 is cast to the string "one hundred seventeen."

The strings.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\dapi\strings\src directory is the Visual C++ workspace file for this DataBlade module.

TopK Terms DataBlade Module

The TopK Terms DataBlade module illustrates how to take a set as an argument and returning a set with a user-defined iterator function. The TopK() function finds the top k integer terms from a set of integers.

The topk.dsw file in the %INFORMIXDIR%\dbdk\examples\routines\dapi\topkterms\src directory is the Visual C++ workspace file for this DataBlade module.

UDTExporter DataBlade Module

The UDTExporter DataBlade module illustrates how to use extended data types on an ESQL/C and a C++ client. The UDTExporter DataBlade module contains row data types, collection data types, an opaque data type (ComplexNumber), qualified data types, and distinct data types. Two additional programs are provided: an ESQL/C program, udtexpo.ec, in the %INFORMIXDIR%\dbdk\examples\Client\esqlc\UDTExporter directory; and a C++ program, cppclient.cpp, in the %INFORMIXDIR%\dbdk\examples\Client\c++api\UDTExporter directory. These programs illustrate:

  • creating tables with each kind of data provided in the DataBlade module.
  • inserting values into the tables.
  • retrieving values from the tables.

For information on how to run the client programs, see the readme.txt file for ESQL/C client and the readme.txt file for C++.

For the ESQL/C program, the udtexporter.dsw file is the source code for the ComplexNumber data type support routines.

For the C++ program, the udtexporter.dsw file is the source code for the ComplexNumber data type support routines.