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

Add litemap crate (TupleVecMap) #496

Merged
merged 9 commits into from
Feb 23, 2021
Merged

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Feb 17, 2021

Fixes #484

Somewhat WIP: I want to add doctests and use it in icu4x itself.

This is currently in tree, eventually I think this should be maintained out-of-tree as a general purpose utility, but for now I didn't want to figure that out and it should be fine here.

@zbraniecki: I'm not super happy with the name, I picked it as a kind of ironic "haha, it's a flat map" thing, but I couldn't think of great names. I would have liked mercator since it's a map projection, but that's taken, and the obvious vec-map is too. Unsure if the type itself should be called FlattenedMap or something, and FlatMap has another connotation.

@Manishearth Manishearth requested a review from a team as a code owner February 17, 2021 01:50
@Manishearth Manishearth requested review from echeran and sffc February 17, 2021 01:50
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
echeran
echeran previously approved these changes Feb 17, 2021
Copy link
Contributor

@echeran echeran left a comment

Choose a reason for hiding this comment

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

LGTM.

For bonus points in the future, you can see if there's a threshold of the size under which it's faster to just iterate over the elements instead of binary search. For Clojure's array-map, it's apparently 9, and then it auto-upgrades itself to a BTreeMap-esque Map (HAMT).

utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • utils/terrain/src/map.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • utils/terrain/src/map.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@coveralls
Copy link

coveralls commented Feb 17, 2021

Pull Request Test Coverage Report for Build 040c69ba2da56a7a79fec9f291bc5081b7b4e63b-PR-496

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 72.752%

Totals Coverage Status
Change from base Build 3be597cdf89432e493e7777bb4dec54854a47f97: 0.004%
Covered Lines: 4886
Relevant Lines: 6716

💛 - Coveralls

@codecov-io
Copy link

Codecov Report

Merging #496 (e3c1f6d) into master (3be597c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #496   +/-   ##
=======================================
  Coverage   73.35%   73.36%           
=======================================
  Files         117      118    +1     
  Lines        6501     6502    +1     
=======================================
+ Hits         4769     4770    +1     
  Misses       1732     1732           
Impacted Files Coverage Δ
utils/terrain/src/lib.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3be597c...8f2a5ac. Read the comment docs.

@Manishearth
Copy link
Member Author

Added doctests. Are there specific places folks want me to use this? Also, I haven't added a requirement that all keys be Copy, but I could.

Another potential performance win is splitting the vectors into two for cache reasons, but I don't think it will matter unless V is very big.

utils/terrain/Cargo.toml Outdated Show resolved Hide resolved
utils/terrain/src/lib.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
zbraniecki
zbraniecki previously approved these changes Feb 18, 2021
Copy link
Member

@zbraniecki zbraniecki left a comment

Choose a reason for hiding this comment

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

lgtm!

# (online at: https://github.com/unicode-org/icu4x/blob/master/LICENSE ).

[package]
name = "terrain"
Copy link
Member

Choose a reason for hiding this comment

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

I have a small to moderate preference for using a functional name like "sorted_vec_map", only because "terrain" isn't really that good of a name for what we're building.

utils/terrain/src/map.rs Outdated Show resolved Hide resolved
utils/terrain/src/map.rs Outdated Show resolved Hide resolved
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

Two things:

  1. You need to run cargo fmt
  2. Let's decide the name of the crate in the meeting tomorrow

@Manishearth Manishearth changed the title Add terrain crate (TupleVecMap) Add litemap crate (TupleVecMap) Feb 18, 2021
@Manishearth Manishearth requested a review from sffc February 18, 2021 18:41
zbraniecki
zbraniecki previously approved these changes Feb 18, 2021
@Manishearth
Copy link
Member Author

Why does CI fail on Cargo.lock changes?

sffc
sffc previously approved these changes Feb 19, 2021
@sffc
Copy link
Member

sffc commented Feb 19, 2021

CC @gregtatum @echeran: can you see what's going on with Cargo.lock?

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • Cargo.lock is different
  • utils/litemap/src/map.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

zbraniecki
zbraniecki previously approved these changes Feb 22, 2021
Copy link
Member

@zbraniecki zbraniecki left a comment

Choose a reason for hiding this comment

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

lgtm!
Please, file a follow up to add serde support.

@Manishearth
Copy link
Member Author

Will do once this merges -- @echeran know what to do about the Cargo.lock issues in the tests?

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • utils/litemap/src/map.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@Manishearth
Copy link
Member Author

Wait, no, that fixed itself somehow

@Manishearth
Copy link
Member Author

Needs final r+ to merge

@Manishearth Manishearth merged commit fdd3a0b into unicode-org:master Feb 23, 2021
@Manishearth Manishearth deleted the terrain branch February 23, 2021 00:59
@Manishearth
Copy link
Member Author

#500

@zbraniecki zbraniecki mentioned this pull request Apr 14, 2021
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create Map interface for TupleVecMap
7 participants