Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

SetFileSegments Function

The SetFileSegments() function is defined as follows:

COUNT SetFileSegments(FILNO filno, NINT aseg, NINT tseg, pSEGMDEF pseg)

Parameter

Description

filno

The file number of an open file

aseg

Specifies the number of active segments, i.e., the segments created immediately. aseg must be at least one and less than or equal to tseg.

tseg

Specifies the total number of segments pointed to by pseg.

pseg

Points to an array of SEGMDEF structures described below.

If the first segment definition pointed to by pseg has an sgname pointing to the empty string, (i.e. *sgname == ‘\0’, not sgname == NULL) the sgsize member of the structure becomes the host segment size limit. Only the last segment can have a size limit of zero, which is interpreted as no limit. If the first segment definition pointed to by pseg does not have an sgname pointing to the empty string, then this sgname applies to the second segment.

Additional segments automatically become active as needed, up to the maximum set in tseg. The segments are used in the order defined by the array of SEGMDEF structures pointed to by pseg.

The file referenced by filno must be opened in ctEXCLUSIVE mode the first time SetFileSegments() is called. Note that a file which has been created and not yet closed is always in ctEXCLUSIVE mode, regardless of the file mode specified as part of the create call. After the segment definitions have been established by the first call to SetFileSegments(), it is possible to call SetFileSegments() to modify the segment definitions even while the file is being updated in client/server models. However, it is not possible to change a segment size so that the new size is smaller than the actual physical size of the segment, nor can a segment size be increased if the segment has already reached its previously specified size, nor can SetFileSegments() rename a segment that is in use. A segment is in use if data beyond the segment header information has been written to the segment. An active segment is not in use just because it is on disk; data must have been written to it. Therefore, a call to SetFileSegments() can, in real time, change where segments will reside (provided the segment is not already in use) and/or how large they are (provided the new size is not smaller than the current physical size or that the segment has already been completely filled with data).

Note: The fxtsiz member of the XCREblk structure cannot be set higher than the size of the first (host) segment during a file create. This will result in a SEGM_ERR (674) error signifying the need for more segments, which do not exist yet because SetFileSegments() has not yet been called.

TOCIndex