Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Key Segment Modes

An ISAM key is composed of one or more key segments. The Key Segment Mode value tells c-tree how to locate the information necessary to create the key segment (the segment position and segment length) and how to translate it, if necessary (the segment mode).

The following table lists the valid key segment mode values. When creating an Incremental ISAM ISEG structure, use the mode value or the symbolic constant. When using an ISAM parameter file, the Key Segment Description record requires the mode value. The segment position interpretation column describes which of the three segment position types defined at the end of the previous section this mode represents.

Mode Value

Symbolic Constant

Segment Position Interpretation

Explanation

0

REGSEG

Absolute byte offset

Regular segment. No transformation.

1

INTSEG

Absolute byte offset

Unsigned integer/long.

2

UREGSEG

Absolute byte offset

Lower-case letters converted to upper case.

3

SRLSEG

Absolute byte offset

Automatic 4-byte/8-byte sequence number.

4

VARSEG

Relative field #

Variable-length segment. No transformation, pad to length.

5

UVARSEG

Relative field #

Lower-case letters are converted to upper case, pad to length.

6

YOURSEG1

 

Reserved for your use.

7

YOURSEG2

 

Reserved for your use.

8

SGNSEG

Absolute byte offset

Signed integer/long.

9

FLTSEG

Absolute byte offset

Floating point (float or double).

10

DECSEG

Absolute byte offset

Scaled BCD.

11

BCDSEG

Absolute byte offset

RESERVED FOR FUTURE USE.

 

12

SCHSEG

Schema field number

Transform according to the underlying data type, pad varying-length string fields.

13

USCHSEG

Schema field number

Transform according to the underlying data type, convert lower case letters to upper case, pad varying-length string fields.

14

VSCHSEG

Schema field number

Transform according to the underlying data type, pad fixed or varying-length string fields.

15

UVSCHSEG

Schema field number

Transform according to the underlying data type, convert lower case letters to upper case, pad fixed or varying length string fields.

These values can be OR'd with the other segment modes.

16

DSCSEG

Descending segment mode

Force the segment to be collated in descending (instead of ascending) order. See Descending Key Segment Values.

32

ALTSEG

Alternative Collating segment mode

Allows the key segment to be stored in other than the standard ASCII collating sequence. See Alternative Collating Sequence.

64

ENDSEG

END segment mode

Used for searching the trailing end of a key segment. See END of Key Segment.

256

RECBYT

RECBYT segment mode

Used for improved variable-length deleted space management. See RECBYT Segment Mode.

257

SCHSRL

Schema field number

Schema-based SRLSEG: Automatic 4- or 8-byte sequence number.

258

BITSEG

Schema field number of bitmask field

Bitmask segment: set soffset to schema field number of null bit mask; set slength to schema field number of target field.

259

ALLNULLDUPSEG

Ignored

Allow duplicate key values when all of the indexed fields are NULL: set soffset to zero (it is ignored); set slength to size of record offset (4 or 8).

260

ANYNULLDUPSEG

Ignored

Allow duplicate key values when any of the indexed fields are NULL: set soffset to zero (it is ignored); set slength to size of record offset (4 or 8).

Don’t be overwhelmed by the number of key segment modes. For fixed-length records there are just a few variations. If you are not sure what to use, start with REGSEG. This takes the value just as it is found in the record, at a given position. If the data field is an unsigned integer, signed integer, floating point or a BCD number, use the appropriate key segment mode. c-tree does the necessary transformations to make the key sort in the appropriate order.

Another basic mode is UREGSEG, which translates lower case letters into upper case letters. If you look at the ASCII collating sequence you will see that all lower case letters come after all upper case letters. If you had “ABC”, “DEF” and “bcd” as key values, they would sort in the sequence if you did not use UREGSEG:

ABC DEF bcd

Most likely, this is not the order that you want the keys in. By using UREGSEG, the lower case letters will be translated to upper case, so the sequence would be:

ABC BCD DEF

Fields in the variable-length portion of a variable-length record must be handled a little differently. Since we cannot predict an absolute byte offset for these fields, we have to be able to calculate a position by counting field delimiters. Use VARSEG or UVARSEG. Since the key must be a particular length, c-tree pads it to the proper length.

Key segment modes 12-15 relate to Record Schemas, described in Record Schemas.

For more information, see ISEG Structure.

In This Section

Key Value Assembly

Sequence Number Segments

Descending Key Segment Values

Alternative Collating Sequence

END of Key Segment

RECBYT Segment Mode

TOCIndex