Sort(SSM )

Shore Programmer's Manual - 2 August 96

NAME

sort_file \- Class ss_m Sorting Methods

SYNOPSIS

#include <sm_vas.h>  // which includes sm.h

static rc_t                 sort_file(
    const lvid_t&               lvid,		// logical vol id (input file)
    const serial_t&             serial,		// serial no for input file
    const lvid_t&               s_lvid, 	// logical vol id (output file)
    serial_t&                   s_serial, 	// serial no for output file
    store_property_t            property,	// property for output file
    const key_info_t&           key_info, 	// sort key info
    int                         run_size,	// # of pages for each run
    bool                        unique = false, // eliminate duplicates
    bool                        destructive = false); // destroy input file 

DESCRIPTION

Method ss_m::sort_file is an external sorting utility to sort an existing file in the order of specified keys. Current release only supports following built-in sort key types: integer, float, char, string and spatial (rectangles on their Hilbert value). Sorting on variable length keys is not supported currently.

User can control the buffer size needed for the sorting by specifying the desired run_size. Usually the bigger the run_size, the faster the sort.

User need to provide detail information on the sort key in key_info. This includes information such as type, location and length. The location of the key has to be fixed offset from the beginning of the record. Class key_info_t is further described in sort_stream_i(ssm) .

Setting the unique flag to true will eliminate duplicate records in the file. Setting Setting the destructive to true will destroy the input file and map the records' logical IDs to those in the new sorted file.

For sorting on variable length records (keys may not stay at fixed location within records), one can fix the key location by copying the key from body to the beginning of hdr for the record, turn on derived flag in key_info before invoking sort_file. The result file will have the duplicated key eliminated in each record.

ERRORS

RCOK is returned if there is no lower level error.

EXAMPLES

To sort a file on integer key which is the first field inside each record body, specify the key_info as below:

key_info.type = t_int;
key_info.where = t_body;
key_info.offset = 0;
key_info.len = sizeof(int);

VERSION

This manual page applies to Version 1.0 of theShore software.

SPONSORSHIP

The Shore project is sponsored by the Advanced Research Project Agency, ARPA order number 018 (formerly 8230), monitored by the U.S. Army Research Laboratory under contract DAAB07-92-C-Q508.

COPYRIGHT

Copyright (c) 1994, 1995, 1996 Computer Sciences Department, University of Wisconsin -- Madison. All Rights Reserved.

SEE ALSO

sort_stream_i(ssm) , file(ssm) ,