// Grid File Interface April 10, 1995 //*********************** GridFile ****************************** #include class GridFile: public IndexFile { friend class GridFileScan; public: GridFile::GridFile (Status &status, const char * filename, (const void * KeyTypes, const int max_string_length = 32, const int num_dimensions = 2) //Status returns the status of this operation. //filename is name of file. //num_dimensions is number of index dimensions AND types in KeyTypes //KeyTypes is array of AttrType where each item is the type of the // corresponding dimension (numbered from 0) and then the // array is cast to type (void *) . // If GridFile index already exists, it is opened else // it is created. // Dimensions and key types are stored in private class // variables for subsequent use by all GridFile procedures. GridFile::GridFile (Status &status, char * filename) //If GridFile index exists, opens it else error. //Status returns the status of this operation. GridFile::~GridFile () //destructor closes index Status GridFile:insert_record(const void * KeyArray, const RID rid) // KeyArray is actually an array of pointers to voids the whole thing // cast to a void pointer. These are // the keys for the respective dimensions being used. The array // must have an entry for each dimension 0 to // num_dimensions - 1. No dimension key value should be unspecified // in insert_record. Status GridFile:delete_record(const void * KeyArray, const RID rid) // KeyArray is actually an array of pointers to voids the whole thing // cast to a void pointer. These are // the keys for the respective dimensions being used. The array // must have an entry for each dimension 0 to // num_dimensions - 1. No dimension key value should be unspecified // in delete_record. IndexFileScan * GridFile::new_scan (const void * LowKeys, const void * HighKeys) } //***************************** Scans **************************** GridFile_scan: public IndexFileScan {public: Status GridFile_scan:: get_next (RID & record_id) // Scan returns next record qualifies under ongoing scan if // there is one. Status GridFile_scan::delete_current_record() // Scan deletes current record private: Status GridFile_scan::GridFile_scan(GridFile * fileptr) //Full scan on given gridfile. Status GridFile_scan::GridFile_scan(GridFile * fileptr, const void *KeyArray) //Create a case of an exact scan on given gridfile. //If a key is not being specified here then its pointer must // be set to null in the KeyArray. Looks for exact match on // keys that are specified. Key's dimension and type must // match as in insert_record and delete_record. Status GridFile_scan::GridFile_scan(GridFile * fileptr, const void *LowKeys, const void *HighKeys) //Create a case of min/max scan on given gridfile. //If a key is not being specified here then its pointer must // be set to null in the KeyArray. // Key's dimension and type must // match as in insert_record and delete_record. }