Rebuilding a keyed file’s secondary indexes

kfbuild

Rebuild a keyed file’s secondary indexes


SYNTAX

kfbuild [-chqv] [-F tempfile] filename [filename]… | -iname [-iname]… filename

Rebuilds a secondary file index or indexes from the main file. This may be necessary for one of two reasons:

1

The secondary index file is damaged.

2

One or more new secondary indexes have been added to an existing file by means of the ddeditor program. Use kfbuild to create the new indexes from the existing data.

For each filename specified, kfbuild reads the data dictionary (.d) file to determine the index key structure, then reads the data file and creates the indexes required. The indexes are placed in a directory called filename.x.

Note that the main index file must be undamaged in order to use kfbuild. If this file is missing or damaged, the kfbuild program will fail. In this case, use the kfri program to rebuild the main index.

A secondary index may be quickly and conveniently (re)built by means of the Sculptor File Manager. Use the Keyed file->Rebuild menu option and select the index or indexes to be built from the Indexes table.

filename

The name of the main file. kfbuild accepts multiple filenames provided that the -i option is not used. All the secondary indexes associated with each file named are rebuilt.

The -i option may only be used if a single filename is specified. It is for the purpose of specifying a particular index or indexes to be rebuilt, rather than allowing Sculptor to rebuild every index associated with the file.

Each filename should be the name of a Sculptor keyed file. The path should be included if the file is not located in the current working directory. Three physical files are actually required: the data dictionary file (.d extension), index file (.k extension) and data file (no extension) must all be present. The .d extension may, optionally, be included in the filename. This allows the form:

kfbuild *.d

to be used if required to rebuild all the secondary indexes associated with files in a particular directory.

[-chqv]
-iname
-F tempfile

Command line options.


Command line options

-c

Displays a count every 1000 records processed.

-h

Displays a help screen listing these options. No other action is taken, even if filenames and other flags are present.

-F tempfile

Places all messages that would normally be displayed on the terminal in the named file and suppresses all questions.

-iname

Specifies an index to be rebuilt. This option is only available if a single filename is specified. However, several different indexes for the specified file may be selected in this way, by repeating the -i option:

kfbuild -iname -inamefilename

-q

Suppresses the output of all messages.

-v

Outputs version information. No other action is taken.


Error messages

Cannot build a good index as data file is badly damaged.

Options:-

1

Reload file from last backup

2

Use kfcopy to copy available data

The data file is damaged and cannot be used to build indexes. Some data retrieval is required. This can in most cases be done by recovering the data file from the most recent backup, or by copying the good records from the damaged file with the kfcopy program, thus ensuring that as much data as possible is retrieved. Then run kfbuild again.


Cannot prepare indices for filename

It is not possible for kfbuild to create secondary index files for the filename specified. A possible reason for this error is that file or directory permissions do not allow the file to be created.


Could not open a keyed file associated with filename for reading

The main keyed file is missing or damaged. The kfbuild program requires this file to be present and intact. Run the kfri program to repair the main index before running kfbuild.


Could not open descriptor file filename, system error nnn.

The kfbuild program cannot access the data dictionary (.d) file. This file is required in order to determine the number and nature of the secondary indexes.


Descriptor file filename has no alternate indices

No secondary indexes exist for the file specified. There is nothing to rebuild.

File filename is empty

The data file is empty. There are no records existing, and therefore nothing to rebuild.


Illegal optionx

The option -x is not valid for kfbuild. Check Command line options for valid options.


Insufficient memory
Insufficient memory for record buffer for file filename

There is not enough free memory for kfbuild to function properly.


Multiple main files not allowed when “-i” option is used

Multiple main file names have been specified along with a -i option. The -i option can only be used in conjunction with a single filename.


No such index “name“. This -i option has been ignored.

An index which is not present in the data dictionary of the specified file has been specified with the -i option. This option is ignored. If other indexes are specified they are processed normally.


Please provide index name when using the “-i” option

The index name is missing following the -i option.


EXAMPLES

  1. Rebuild three specified secondary indexes for the file ‘fruit’, showing count:

    kfbuild -c -iapples -iuglis -icherries fruit
    
  2. Rebuild all secondary indexes for three named files:

    kfbuild monkeys parrots treasure
    
  3. Display kfbuild options help screen:

    kfbuild -h
    

RELATED TOPICS

Keyed file utilities

Sculptor keyed files

Data dictionary editor

File Manager

kfcopy

kfri