Product Documentation

Knowledgebase

Previous Topic

Next Topic

Segmented Files

Segmented file support allows a single logical file to occupy multiple physical files. This allows data files to exceed the physical file size limits imposed by the operating system, and when combined with Huge File Support, provides the added benefit of very large file sizes. The physical file segments can be kept together or distributed over multiple volumes.

In This Section

When to Use Segmented Files

Creating Segmented Files

Previous Topic

Next Topic

When to Use Segmented Files

Use segmented files in the following situations:

  • When the total physical size of a FairCom DB file is expected to exceed operating system or file system limits. In this case, the file can be segmented into multiple physical files, each of which is within the system’s file size limitations.
  • When enough total disk space is available for the expected physical file size, but the disk space is spread over multiple volumes. In this case, the file’s various segments can be placed where the disk space is available.

Previous Topic

Next Topic

Creating Segmented Files

Files can be segmented automatically or the size and location of specific segments can be defined programmatically. Follow these steps to create segmented files:

  1. Create an array of extended create block (XCREblk) structures, one for each physical file to be created. Include the following flags as appropriate in the x8mode field of the XCREblk structures:
    1. The ctFILEPOS8 file mode permits huge files. This mode is required if the logical file will exceed 4GB total file size, but is not required for segmented files in general.
    2. The ctSEGAUTO file mode allows automatic segment generation. When this file mode is used, SetFileSegments() is not required. Simply set the host segment size and maximum segments (the segsize and segmax elements of the Extended File Creation Block). All additional segments will be the same size as the host file and will be stored in the same directory. The segment names generated for a file start by adding “.001” to the existing file name, then incrementing the numeric extension. For example: The automatic segment names for the file sample.dat would start with sample.dat.001 and continues with sample.dat.002, and so on.
  2. Call a FairCom DB Xtd8 file creation function, passing it the XCREblk structure array.
  3. If not using automatic segments, define a SEGMDEF structure detailing the segments to be used. To establish the initial segments, call SetFileSegments(), passing it the SEGMDEF structure.

The extended creation functions can only provide minimal information for segmented files. The XCREblk structure only holds the size of the host segment and the maximum number of segments. To fill in the details, the SetFileSegments() function specifies segment definitions for newly created files dynamically while the file is open. Also, SetFileSegments() can optionally set or change the size limit on the host segment. However, SetFileSegments() can only be called for files created with the Xtd8 API, which causes the file to have an extended header.

The Xtd8 create functions always create Extended files, even if no extended features are requested (unless the ctNO_XHDRS file mode is turned on). Files created with the original API (e.g., CreateIFileXtd()) are in the Standard FairCom DB format.

Note: Files are created in ctEXCLUSIVE mode, so you must close and reopen the file after it is created to allow it to be shared. Since files are created in ctEXCLUSIVE mode, this is a convenient time to execute additional configuration functions, such as SetFileSegments() and PutDODA().

TOCIndex