Data structures used for storing text and image data

This section describes the data structures Adaptive Server uses for storing text or image datatypes.

When you allocate text or image data, a 16-byte text pointer is inserted into the row you allocated. Part of this text pointer is a pointer (to a text page number) for the head of the text or image data. This text pointer is known as the first text page (FTP). The FTP is the beginning of a doubly-linked list of text pages.

Once an FTP is allocated for a text or image data, it is never deallocated. If an update to an existing text or image data row results in fewer text pages than are currently allocated to this text or image data, Adaptive Server deallocates the extra text pages. If an update to a text or image data sets the FTP to NULL, all pages except the FTP are deallocated.

The data row and the text or image data have the following relationship:

Each text page of text or image data has the following layout:

Figure 3: Relationship between the textpointer and datarows


Text nodes

A text node is a hierachical tree data structure that maps byte offsets (and character offsets for multibyte servers) to text pages for text data. Text nodes are used for:

Text nodes are optimized for instances where text or image data are typically allocated with multiple runs of consecutive page numbers. For example:

Figure 4: How text or image page numbers are allocated

In this example, the text or image data is made up of three separate runs of consecutive page numbers, (300 to 310), (330 to 345), and (392 to 411). For this case, only three text node entries are needed.

Figure 5 describes the structure of a text node. L0-cache is the text node, and L1 and L2 are indirect nodes that point to text or image data pages.

Figure 5: Structure of the text node

The first section of the text node stored in the L0-cache part of the FTP. Depending on the length of the text data, and how the text pages were allocated, Adaptive Server may allocate extra text pages to store the rest of the text node data structure. These extra text pages are each a text page chain, and are connected to the text data with the FTP of the text datavalue.

Whether or not the text data requires extra pages—and the amount of extra text pages needed—is dependent on the size of the text data, and how ‘consecutive’ the text pages are that are allocated for the text data.