// // $Id: ix.h 2597 2007-11-28 06:17:41Z chenli $ // // Copyright (C) 2007 by The Regents of the University of California // // Redistribution of this file is permitted under the terms of the GNU // Public License (GPL). // // Date: 11/6/2007 // Author: Chen Li #ifndef _ix_h_ #define _ix_h_ #include #include "fs/fs.h" #include "rm/rm.h" using namespace std; class IX_IndexHandle; class IX_Manager { public: IX_Manager (const char *diskName); // Constructor ~IX_Manager (); // Destructor RC setRM(RM &rm); // set the record manager (to get metadata of a table) RC CreateIndex(const char *tableName, // create new index const char *attributeName); RC DestroyIndex(const char *tableName, // destroy an index const char *attributeName); RC OpenIndex(const char *tableName, // open an index const char *attributeName, IX_IndexHandle &indexHandle); RC CloseIndex(IX_IndexHandle &indexHandle); // close index }; class IX_IndexHandle { public: IX_IndexHandle (); // Constructor ~IX_IndexHandle (); // Destructor // The following two functions are using the following // format for the passed key value. // // For int and real: use 4 bytes // For char and varchar: use 4 bytes for the length followed by // the characters RC InsertEntry(void *key, const RID &rid); // Insert new index entry RC DeleteEntry(void *key, const RID &rid); // Delete index entry }; class IX_IndexScan { public: IX_IndexScan(); // Constructor ~IX_IndexScan(); // Destructor // for the format of "value", please see IX_IndexHandle::InsertEntry() RC OpenScan(const IX_IndexHandle &indexHandle, // Initialize index scan CompOp compOp, void *value); RC GetNextEntry(RID &rid); // Get next matching entry RC CloseScan(); // Terminate index scan }; // print out the error message for a given return code void IX_PrintError (RC rc); #endif