Skip to content
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

Merged
merged 67 commits into from
Nov 6, 2023
Merged

use HashMapDictionary #397

merged 67 commits into from
Nov 6, 2023

Conversation

larry-gonzalez
Copy link
Collaborator

  • implementation of HashMapDictionary
  • use HashMapDictionary instead of StringDictionary or PrefixedStringDictionary by default
  • work-in-progress: MetaDictionary
  • work-in-progress: InfixDictionary

@mmarx mmarx added enhancement New feature or request physical physical layer labels Nov 2, 2023
@mmarx mmarx added this to the Release 0.4.0 milestone Nov 2, 2023
Copy link
Member

@mmarx mmarx left a 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.

Comment on lines 46 to 49
//#[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"))]
Copy link
Member

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.

Comment on lines 46 to 47
}
impl AddResult {
Copy link
Member

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.


/// 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
Copy link
Member

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.

nemo-physical/src/dictionary.rs Show resolved Hide resolved
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iner ~> interior
patters ~> pattern

Comment on lines 90 to 91
}
impl DictionaryType {
Copy link
Member

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.

Comment on lines 123 to 124
}
impl DictIterator {
Copy link
Member

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.

Comment on lines 135 to 143
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;
}
}
Copy link
Member

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;
                }
            }

Comment on lines 184 to 185
dictblocks: Vec::new(), //vec![(1, 0)],
dicts: Vec::new(), //vec![default_dict_record, blob_dict_record],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these comments go?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these?

Comment on lines 243 to 250
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;
}
Copy link
Member

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
            };

@larry-gonzalez larry-gonzalez requested a review from mmarx November 6, 2023 09:07
@larry-gonzalez larry-gonzalez merged commit 7b544a1 into main Nov 6, 2023
@mmarx mmarx deleted the dict-exp branch November 6, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request physical physical layer
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants