|
The smart-large-object interface allows you to access the data of a smart large object in much the same way as you would access an operating-system file in the UNIX or Windows NT operating systems. The interface provides the following:
The milo.h header file defines the functions and data structures of the smart-large-object interface. The mi.h header file automatically includes the milo.h header file. You must include either mi.h or milo.h in any DataBlade API routine that calls a smart-large-object function or declares one of the smart-large-object data structures.
Sections of this chapter describe how to use the smart-large-object interface to perform the following operations on a smart large object.
Tip: The DataBlade API also supports the Illustra Large-Object interface for backward compatibility with Illustra products. For more information, see Using the Illustra Large-Object Interface.
Smart-Large-Object Data Structures
The smart-large-object interface provides data structures that store information about a smart large object. Figure 6-4 summarizes the data structures of the smart-large-object interface.
Figure 6-4
These structures are all opaque to a DataBlade API module; that is, you do not access their fields directly but instead use accessor functions that the smart-large-object interface provides.
The LO-specification structure, MI_LO_SPEC, defines the storage characteristics for an existing or a new smart large object. The storage characteristics provide information about features of the smart large object and how to store it on disk. For a description of the storage characteristics available, see Storage Characteristics.
The following table summarizes the memory operations for an LO-specification structure.
Default Memory Duration |
Memory Operation | Function Name |
---|---|---|
Current memory duration | Constructor | mi_lo_spec_init() |
Destructor | mi_lo_spec_free() |
To access an LO-specification structure in a DataBlade API module, declare a pointer to an MI_LO_SPEC structure. For example, the following line shows the valid syntax of a variable that accesses an LO-specification structure:
Declaration of a flat LO-specification structure generates a compile error. The following line shows invalid syntax for an LO-specification structure:
The milo.h header file defines the MI_LO_SPEC data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade API modules that access this structure. For information on how to use an LO-specification structure, see Obtaining the LO-Specification Structure.
The LO handle, MI_LO_HANDLE, serves as a reference to a smart large object. It is analogous to the filename of an operating-system file in that it is a unique identifier of a smart large object. It contains encoded information about the smart large object, such as its physical disk location and other security-related information. Once a smart large object is created, an associated LO handle is a valid reference for the life of that smart large object.
The following table summarizes the memory operations for an LO handle.
Default Memory Duration |
Memory Operation | Function Name |
---|---|---|
Current memory duration | Constructor | mi_get_lo_handle(), mi_lo_copy(), mi_lo_create(), mi_lo_create(), mi_lo_from_buffer(), mi_lo_from_file(), mi_lo_from_string() |
Destructor | mi_lo_release() |
To access an LO handle in a user-defined routine, declare it in one of the following ways:
The milo.h header file defines the MI_LO_HANDLE data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade API modules that access this handle. For information on how to use an LO handle, see Initializing an LO-Specification Structure and Selecting the LO Handle.
The LO file descriptor, MI_LO_FD, is a reference to an open smart large object. An LO file descriptor is similar to a file descriptor for an operating-system file. It is an integer number that serves as a transient descriptor for performing I/O on the data of the smart large object. It provides the following information about an open smart large object:
The following table summarizes the memory operations for an LO file descriptor.
Default Memory Duration |
Memory Operation | Function Name |
---|---|---|
Current memory duration | Constructor | mi_lo_copy(), mi_lo_create(), mi_lo_open() |
Destructor | mi_lo_close() |
To access an LO file descriptor in a DataBlade API module, declare a variable with the MI_LO_FD data type. For example, the following line declares the variable my_lofd that is an LO file descriptor:
The milo.h header file defines the MI_LO_FD data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade API modules that access this handle.
Tip: Other smart-large-object data structures require that you declare a pointer to them because the DataBlade API handles memory allocation for these structures. However, you can directly declare an LO file descriptor.
For information on how to use an LO file descriptor, see Initializing an LO-Specification Structure.
The LO-status structure, MI_LO_STAT, contains the status information for an existing smart large object. The following table summarizes the memory operations for an LO-status structure.
Default Memory Duration |
Memory Operation | Function Name |
---|---|---|
Current memory duration | Constructor | mi_lo_stat() |
Destructor | mi_lo_stat_free() |
To access an LO-status structure in a DataBlade API module, declare a pointer to an MI_LO_STAT structure. For example, the following line declares the variable mystat that points to an LO-specification structure:
Declaration of a flat LO-status structure generates a compile error. The following line shows invalid syntax for an LO-status structure:
The milo.h header file defines the MI_LO_STAT data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade API modules that access this structure. For information on how to allocate and use an LO-status structure, see Obtaining the Status of a Smart Large Object.
The smart-large-object interface includes functions that provide the following operations on a smart large object:
Most of the smart-large-object functions begin with the string mi_lo_. Chapter 15, DataBlade API Function Descriptions, contains an alphabetical list of all DataBlade API functions, including the smart-large-object functions.
The smart-large-object creation functions create a new smart large object, open it, and return a new LO handle and LO file descriptor for it. Figure 6-5 lists the smart-large-object creation functions.
Figure 6-5
For more information on how to use the smart-large-object creation functions, see Creating a Smart Large Object.
The Dynamic Server smart-large-object interface includes functions that provide basic file operations such as create, open, seek, read, write, alter, and truncate. These routines bypass the query processor, executor, and optimizer, and give the application direct access to a smart large object. These functions use an LO file descriptor to identify the open smart large object.
Figure 6-6 shows the basic file-like operations on a smart large object along with the smart-large-object function that performs them and the analogous operating-system calls for file operations.
Figure 6-6
For more information, see Opening a Smart Large Object.
The following table shows the smart-large-object functions that act on an LO handle, not on the smart large object that it represents.
Important: The LO handle, MI_LO_HANDLE, is an opaque structure to DataBlade API modules. Do not access its internal structure directly. Informix does not guarantee that the internal structure of MI_LO_HANDLE will not change. Therefore, to create portable code, use the appropriate DataBlade API function to use this structure.
For more information on how to use these functions, see Obtaining an LO Handle.
The following table shows the smart-large-object functions that access the LO-specification structure.
Important: The LO-specification structure, MI_LO_SPEC, is an opaque structure to DataBlade API modules. Do not access its internal structure directly. Informix does not guarantee that the internal structure of MI_LO_SPEC will not change in future releases. Therefore, to create portable code, always use the LO-specification accessor functions to obtain and store values in this structure.
For more information on how to use these functions, see Obtaining the LO-Specification Structure and Choosing Storage Characteristics.
The following table shows the smart-large-object functions that access the LO-status structure.
Important: The LO-status structure, MI_LO_STAT, is an opaque structure to DataBlade API modules. Do not access its internal structure directly. Informix does not guarantee that the internal structure of MI_LO_STAT will not change in future releases. Therefore, to create portable code, always use the LO-status accessor functions to obtain and store values from this structure.
For more information on how to use these functions, see Obtaining the Status of a Smart Large Object.
The following table shows the smart-large-object functions that move smart large objects to and from operating-system files.
For more information on how to use these functions, see Using Operating-System Files.