diff --git a/DataStructures/DiskHashTable/DiskHashTable.h b/DataStructures/DiskHashTable/DiskHashTable.h index ecb18f63f0ad505e696763a396aa3dd95fee6bc8..19330987f26fcdd9664f5849b4a73641a37d40a4 100644 --- a/DataStructures/DiskHashTable/DiskHashTable.h +++ b/DataStructures/DiskHashTable/DiskHashTable.h @@ -48,8 +48,8 @@ public: maxKeySize = maxKeySize_in; maxValueSize = maxValueSize_in; nodeSize = maxKeySize + maxValueSize + 2; - if(nodeSize % 10 != 0) { - cerr << "The sum of key size + value size + 2 must be divisible by 10!"; + if(1000 % nodeSize != 0) { + cerr << "The sum of key size + value size + 2 must divide a multiple of 1000!"; exit(1); } if(fileSize <= 0) { // no file, or empty file @@ -79,6 +79,14 @@ public: * @return */ bool insert(string key, string value) { + if(key.size() > maxKeySize) { + cerr << "A key you tried to insert into a disk hash table was larger than the set max key size!"; + exit(1); + } + if(value.size() > maxValueSize) { + cerr << "A value you tried to insert into a disk hash table was larger than the set max value size!"; + exit(1); + } if((double) size / capacity >= 0.75) { rehash(); } diff --git a/crawler-parser-indexer-test b/crawler-parser-indexer-test index 86b211684a48e319aa2f1cc8125d0f28f26bcde1..fb69bc1c4cf3033dd41d399b312241fdffae701d 100755 Binary files a/crawler-parser-indexer-test and b/crawler-parser-indexer-test differ diff --git a/indexer/Indexer.cpp b/indexer/Indexer.cpp index 8b475447d77e41f7044c4950c066a75021cf6cf2..90edd430cfe425ae5d05244151647fbb89e5d5dc 100644 --- a/indexer/Indexer.cpp +++ b/indexer/Indexer.cpp @@ -70,7 +70,7 @@ void Indexer::verbose_run() { void Indexer::save ( ) { map< string, vector< size_t > > maps( masterDictionary.begin( ), masterDictionary.end( ) ); - DiskHashTable seeker(util::GetCurrentWorkingDir( ) + "/indexer/output/" + to_string( currentFile ) + "-seek.txt", 20, 8 ); + DiskHashTable seeker(util::GetCurrentWorkingDir( ) + "/indexer/output/" + to_string( currentFile ) + "-seek.txt", 30, 8 ); string fileName = util::GetCurrentWorkingDir( ) + "/indexer/output/" + to_string( currentFile ) + ".txt"; int file = open( fileName.c_str( ), O_CREAT | O_WRONLY, S_IRWXU );