only hashing first byte to isolate failure
@@ -1013,6 +1013,7 @@ linear_hash_get_record(
/* cache record data from file */
ion_byte_t *record = alloca(linear_hash->record_total_size);
+
if (1 != fread(record, linear_hash->record_total_size, 1, linear_hash->database)) {
return err_file_read_error;
}
@@ -1141,6 +1142,7 @@ linear_hash_get_bucket(
if (0 != fseek(linear_hash->database, bucket_loc, SEEK_SET)) {
return err_file_bad_seek;
}
+
/* check if file is open */
if (!linear_hash->database) {
return err_file_close_error;
@@ -1318,14 +1320,17 @@ key_bytes_to_int(
ion_byte_t *key,
linear_hash_table_t *linear_hash
) {
+ /*
int i;
- int key_bytes_as_int = 0;
+ long key_bytes_as_int = 0;
for (i = 0; i < linear_hash->super.record.key_size; i++) {
key_bytes_as_int += *(key + i);
}
return key_bytes_as_int;
+ */
+ return *key;
}
int
@@ -1336,10 +1341,9 @@ hash_to_bucket(
/* Case the record we are looking for was in a bucket that has already been split and h1 was used */
int key_bytes_as_int = key_bytes_to_int(key, linear_hash);
- return hash(key_bytes_as_int) & ((2 * linear_hash->initial_size) - 1);
+ return key_bytes_as_int & ((2 * linear_hash->initial_size) - 1);
}
-/* TODO change back to ion_key_t */
int
insert_hash_to_bucket(
ion_byte_t *key,
@@ -1347,7 +1351,7 @@ insert_hash_to_bucket(
) {
int key_bytes_as_int = key_bytes_to_int(key, linear_hash);
- return hash(key_bytes_as_int) & (linear_hash->initial_size - 1);
+ return key_bytes_as_int & (linear_hash->initial_size - 1);
}
/* Write the offset of bucket idx to the map in linear hash state */
