-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use HashMapDictionary #397
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a lot of (mostly stylistic) changes, but this looks quite good already. In addition to my comments, there's also several clippy
lints and some issues with the documentation.
//#[cfg(feature = "no-prefixed-string-dictionary")] | ||
/// Dictionary Implementation used in the current configuration | ||
pub type Dict = crate::dictionary::StringDictionary; | ||
#[cfg(not(feature = "no-prefixed-string-dictionary"))] | ||
//pub type Dict = crate::dictionary::StringDictionary; | ||
//#[cfg(not(feature = "no-prefixed-string-dictionary"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please just remove these instead of only commenting them out, and also remove the features in the nemo{,-physical,cli}
crates.
nemo-physical/src/dictionary.rs
Outdated
} | ||
impl AddResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please separate enum
and impl
with a blank line.
nemo-physical/src/dictionary.rs
Outdated
|
||
/// Marks the given string as being known using the special id [KNOWN_ID_MARK] without | ||
/// assigning an own id to it. If the entry exists already, the old id will be kept and | ||
/// returned. If is possible to return [AddResult::Rejected] to indicate that the dictionary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If is
: there seems to be a word missing here.
pub(crate) const LONG_STRING_THRESHOLD: usize = 1000; | ||
|
||
/// Inner struct where keep locations extracted from strings. This is separated | ||
/// to enable an iner mutability patters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iner
~> interior
patters
~> pattern
} | ||
impl DictionaryType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, please add a blank line.
} | ||
impl DictIterator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, please add a blank line.
if ds.infixable() { | ||
#[allow(trivial_casts)] | ||
if let Some(dict_idx) = md | ||
.infix_dicts | ||
.get((ds.prefix(), ds.suffix()).borrow() as &dyn StringPairKey) | ||
{ | ||
return *dict_idx; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ds.infixable() {
if let Some(dict_idx) = md
.infix_dicts
.get::<dyn StringPairKey>(&(ds.prefix(), ds.suffix()))
{
return *dict_idx;
}
}
dictblocks: Vec::new(), //vec![(1, 0)], | ||
dicts: Vec::new(), //vec![default_dict_record, blob_dict_record], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these comments go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about these?
let mut new_block: usize; | ||
if btl_index > 0 { | ||
// extrapolate where global block should be relative to last allocated local block | ||
new_block = self.dicts[dict].gblocks[btl_index - 1] + btl_index - 1; | ||
} else { | ||
// TODO determine "good" initial block for this dictionary | ||
new_block = 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut new_block = if btl_index > 0 {
// extrapolate where global block should be relative to last allocated local block
self.dicts[dict].gblocks[btl_index - 1] + btl_index - 1
} else {
// TODO determine "good" initial block for this dictionary
0
};
…unsafe inside; creating constants
HashMapDictionary
HashMapDictionary
instead ofStringDictionary
orPrefixedStringDictionary
by defaultMetaDictionary
InfixDictionary