Lo file descriptor
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.
A LO file descriptor provides the following information
about an open smart large object:
- The LO seek position, the current position at which read and write
operations occur.
When you first open a smart large object, the seek position is at byte zero.
- The open mode of the smart large object, which determines which
operations can be performed on the data and how to buffer the data
for I/O operations.
You specify the open mode when you open a smart large object.
The following table summarizes the memory operations for
an LO file descriptor.
Memory duration | Memory operation | Function name |
---|---|---|
Not allocated from memory-duration pools | Constructor | mi_lo_copy(), mi_lo_create(), mi_lo_expand(), mi_lo_from_file(), mi_lo_open() |
Not allocated from memory-duration pools | 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:
MI_LO_FD my_lofd;
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 type structures require that you declare a pointer to them because
the DataBlade
API handles
memory allocation for these structures. However, you can declare an
LO file descriptor directly.
Server only:
Because you
declare an LO file descriptor directly, its scope is that of the variable
you declare to hold it. When you assign an LO file descriptor to a
local variable, the LO file descriptor is deallocated when the function
that declares it ends. If you want to keep the LO file descriptor
longer, you can allocate user memory with the memory duration you
want (up to the advanced duration of PER_SESSION) and copy the LO
file descriptor into this memory. For example, you can assign the
LO file descriptor to PER_COMMAND memory and copy it into the user
state of the MI_FPARAM structure.
Important: Although
the scope of an LO file descriptor is determined by its declaration,
the scope of the open smart large object (which the LO file descriptor
identifies) is the entire session. Make sure you explicitly close
a smart large object before the scope of its LO file descriptor expires.