This new range operator can retrieve key ranges defined over a group of contiguous key segments.
The FairCom DB range retrieval function (e.g., AllocateRange) previously operated at the key segment level. In V11.5 and later, it has been enhanced to support a range operator that can be used to perform retrievals on key ranges that are defined over a set of contiguous key segments (referred to here as a “virtual segment group”).
This feature allows you to search for all entries at the key level between two targets: from a low-key to a high-key and from a lower-bound to an upper-bound. By introducing support for grouping two or more contiguous segments into one virtual segment group, it is now possible to perform a new type of range retrieval.
As an example, consider a database that contains two fields of one character each:
"First", CT_FSTRING, 1
"Second", CT_FSTRING, 1
The index would consist of two segments, one for each field.
For this example, assume the data in these fields is as follows:
(A, 1)
(A, 7)
(A, 9)
(A, 11)
(B, 1)
(B, 2)
(B, 5)
(C, 1)
(C, 2)
(C, 5)
It has always been possible to specify a key range that would get us all of the records where the first field is A or an even more complex range where the first field is between A and B and the second field is between 1 and 3. That would get us the following records:
(A, 1)
(B, 1)
(B, 2)
(C, 1)
(C, 2)
A sequential range of records between (A, 7) and (C, 2) is a more challenging case. It would require maintaining a second index of a single segment that includes the first field and the second field. This solution was not possible unless the two fields were adjacent to each other and in the correct order in the database.
With virtual segment group support, we can specify a key range involving two or more index segments, which are adjacent in the index, and treat them as a single segment. The fields need not be adjacent in the database. In our example, that would allow us to specify a key range from (A, 7) to (C, 2), which would get us the following records:
(A, 7)
(A, 9)
(A, 11)
(B, 1)
(B, 2)
(B, 5)
(C, 1)
(C, 2)
New Range Operator Modifiers
This revision introduces two range operator modifiers to be OR-ed in to the operator parameter values passed to AllocateRange():
Example:
NINT oper[2],rc;
oper[1] = CTIX_BET | CTIX_SSG; /* first segment: start segment group */
oper[2] = CTIX_BET | CTIX_ESG; /* second segment: end segment group */
rc = AllocateRange(keyno, 2, ""A4"", ""C6"", &oper);