DBMS Requirements: HashTable

Class HashTable {

bool connect(const char* aUserName, const char* aPassword);

bool disconnect();

bool openTable(const char* aTableName);

bool hash();

void* find(int aValue);

bool closeTable();

}

HashTable Guidelines

  1. Assume table has only one field of type integer.
  2. Use DBAPI classes to implement the above methods.
  3. hash() method should retrieve all the record pointers using table->fetch() and hash it .
  4. Based on the table->numTuples(), compute bucket size.
  5. find(value) should return pointer to the record where the passed value is stored.

%%

HashTable Usage

int main() {

bool ret;

HashTable sTable;

ret = sTable.connect("root", "manager");

ret = sTable.openTable("T1");

sTable.hash();

void* record = sTable.find(102);

printf("Record ptr is %x and value is %d\n", record, *(int*) record);

sTable.closeTable();

sTable.disconnect();

return 0;

}

Assumption: Table T1 with field f1 of type int already exists in database