Revert last commit
Accidentally kept the hashing and when I removed it the solution slowed down again
This reverts commit aaa11c7b94
.
This commit is contained in:
parent
aaa11c7b94
commit
7b8943976f
@ -1,4 +1,3 @@
|
||||
use crate::models::hasher::CustomBuildHasher;
|
||||
use crate::models::station_measurements::StationMeasurements;
|
||||
use crate::utils::{hash, parse};
|
||||
use std::collections::HashMap;
|
||||
@ -13,9 +12,8 @@ pub fn run() {
|
||||
const FILE_PATH: &str = "../../../measurements.txt";
|
||||
let now = Instant::now();
|
||||
thread::scope(|s| {
|
||||
let hasher = CustomBuildHasher::default();
|
||||
let mut stations: HashMap<u64, (String, StationMeasurements), CustomBuildHasher> =
|
||||
HashMap::with_capacity_and_hasher(DEFAULT_HASHMAP_LENGTH, hasher);
|
||||
let mut stations: HashMap<u64, (String, StationMeasurements)> =
|
||||
HashMap::with_capacity(DEFAULT_HASHMAP_LENGTH);
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let cores = thread::available_parallelism().unwrap().into();
|
||||
let file = File::open(FILE_PATH).expect("File measurements.txt not found");
|
||||
@ -46,9 +44,8 @@ pub fn run() {
|
||||
let file = File::open(FILE_PATH).expect("File measurements.txt not found");
|
||||
let mut reader = BufReader::new(&file);
|
||||
reader.seek(SeekFrom::Start(currposition)).unwrap();
|
||||
let hasher = CustomBuildHasher::default();
|
||||
let mut t_stations: HashMap<u64, (String, StationMeasurements), CustomBuildHasher> =
|
||||
HashMap::with_capacity_and_hasher(DEFAULT_HASHMAP_LENGTH, hasher);
|
||||
let mut t_stations: HashMap<u64, (String, StationMeasurements)> =
|
||||
HashMap::with_capacity(DEFAULT_HASHMAP_LENGTH);
|
||||
let mut line = Vec::with_capacity(108);
|
||||
loop {
|
||||
let line_len = reader
|
||||
|
@ -1,3 +1,2 @@
|
||||
pub mod mmap;
|
||||
pub mod station_measurements;
|
||||
pub mod hasher;
|
||||
|
@ -1,33 +0,0 @@
|
||||
use std::hash::{BuildHasherDefault, Hasher};
|
||||
use crate::utils::hash;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct CustomHasher(u64);
|
||||
|
||||
impl Default for CustomHasher {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
CustomHasher(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl CustomHasher {
|
||||
#[inline]
|
||||
pub fn with_key(key: u64) -> CustomHasher {
|
||||
CustomHasher(key)
|
||||
}
|
||||
}
|
||||
|
||||
impl Hasher for CustomHasher {
|
||||
#[inline]
|
||||
fn finish(&self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write(&mut self, bytes: &[u8]) {
|
||||
*self = CustomHasher(hash::bytes(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
pub type CustomBuildHasher = BuildHasherDefault<CustomHasher>;
|
Loading…
Reference in New Issue
Block a user