#include #include #include #include #include "Join.hpp" #include "Record.hpp" #include "Page.hpp" #include "Disk.hpp" #include "Mem.hpp" #include "Bucket.hpp" #include "constants.hpp" #include using namespace std; void print(vector &join_res, Disk* disk) { cout << "Size of GHJ result: " << join_res.size() << " pages" << endl; for (unsigned int i = 0; i < join_res.size(); ++i) { Page *join_page = disk->diskRead(join_res[i]); cout << "Page " << i << " with disk id = " << join_res[i] << endl; join_page->print(); } } int main(int argc, char* argv[]) { /* Parse cmd arguments */ if (argc != 3) { cerr << "Error: Wrong command line usage." << endl; cerr << "Usage: ./GHJ left_rel.txt right_rel.txt" << endl; exit(1); } /* Variable initialization */ Disk disk = Disk(); Mem mem = Mem(); pair left_rel = disk.read_data(argv[1]); pair right_rel = disk.read_data(argv[2]); /* Grace Hash Join Partition Phase */ vector res = partition(&disk, &mem, left_rel, right_rel); /* Grace Hash Join Probe Phase */ vector join_res = probe(&disk, &mem, res); /* Print the result */ print(join_res, &disk); return 0; }