You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't know if it's necessary because the performance should now be good enough and it might bring unncessary overhead.
But it'd be fun to create an index for using binary search for artists as well.
Probably not really feasible, because the functions accept [SongEntry] and not SongEntries - meaning I'd have to put the index as another argument or make the argument SongEntries with the index as an attribute...
You could create the index while parsing the endsong files.
assert!(start <= end,"Start date is after end date!");
let begin = match entries.binary_search_by(|entry| entry.timestamp.cmp(start)){
// timestamp from entry
Ok(i) => i,
// user inputted date - i because you want it to begin at the closest entry
Err(i)if i != entries.len() => i,
// user inputted date that's after the last entry
Err(_) => entries.len() - 1,
};
let stop = match entries.binary_search_by(|entry| entry.timestamp.cmp(end)){
// timestamp from entry
Ok(i) => i,
// user inputted date - i-1 becuase i would include one entry too much
Err(i)if i != 0 => i - 1,
// user inputted date that's before the first entry
Err(_) => 0,
};
entries[begin..=stop]
.iter()
.filter(|entry| aspect.is_entry(entry))
.count()
}
instead of that linear scan at the bottom you could do something like (or similar, haven't thought exactly about how you'd access it) artist_index[artist].unwrap()[begin..=stop].len()
And the index would be a collection of artists with a list of the indexes those artists appear at
Implementation details tbd
Ofc, this would also only work for artists, while this function accepts Artists, Albums and Songs... So you could create other indexes for them or separate the function
...or probably just let it be because it isn't a good idea :P
The text was updated successfully, but these errors were encountered:
Probably the best structure for the index would be a HashMap where the keys are the artist names (as Strings) and the values are Vec<DateTime<Tz>> with the timestamps of the corresponding entries
Similar to #39
https://youtu.be/KXJSjte_OAI
Don't know if it's necessary because the performance should now be good enough and it might bring unncessary overhead.
But it'd be fun to create an index for using binary search for artists as well.
Probably not really feasible, because the functions accept
[SongEntry]
and notSongEntries
- meaning I'd have to put the index as another argument or make the argumentSongEntries
with the index as an attribute...You could create the index while parsing the endsong files.
rusty-endsong-parser/src/display/date.rs
Lines 109 to 139 in 8c1944c
instead of that linear scan at the bottom you could do something like (or similar, haven't thought exactly about how you'd access it)
artist_index[artist].unwrap()[begin..=stop].len()
And the index would be a collection of artists with a list of the indexes those artists appear at
Implementation details tbd
Ofc, this would also only work for artists, while this function accepts Artists, Albums and Songs... So you could create other indexes for them or separate the function
...or probably just let it be because it isn't a good idea :P
The text was updated successfully, but these errors were encountered: