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

Proposal: change @scopedenum to make modules to avoid type piracy #267

Merged
merged 6 commits into from
Jan 22, 2022

Conversation

NHDaly
Copy link
Contributor

@NHDaly NHDaly commented Dec 17, 2021

This changes the result of @scopedenum to produce a module instead of trying to stick the enums into the enum type, as a proposed fix for #266.

It's admittedly less pretty, but I think it's still pretty nice! It seems like a hopefully somewhat understandable pattern to follow, which is that it pluralizes your enum name to make a module. We communicate that to the users by returning it at the end of the expression:

julia> Arrow.FlatBuffers.@scopedenum MyEnum X=1 Y=2
Main.MyEnums

julia> MyEnums.X
X::MyEnum = 1

I can see why this is less appealing than what was there before, but what is there before suffers from the performance problems identified in #266.

Thanks for your consideration! ❤️

@NHDaly
Copy link
Contributor Author

NHDaly commented Dec 17, 2021

Verifying this fixes #267:

julia> using BenchmarkTools

julia> @btime sort!([rand([Int,Float64,Int8,Int32]) for _ in 1:100], by=fieldcount);
  59.247 μs (103 allocations: 12.33 KiB)

julia> using Arrow
[ Info: Precompiling Arrow [69666777-d1a9-59fb-9406-91d4454c9d45]

julia> @btime sort!([rand([Int,Float64,Int8,Int32]) for _ in 1:100], by=fieldcount);
  53.731 μs (103 allocations: 12.33 KiB)

@ericphanson
Copy link
Member

btw @NHDaly this looks like a great change to me (although I'm not very familiar with the code in question), but FYI commits are frozen for now while they transfer the repo to apache's org (ref #265)

@NHDaly
Copy link
Contributor Author

NHDaly commented Dec 17, 2021

:o oh shoot, thanks @ericphanson! Very interesting. Makes sense.

Thanks. So, should we wait until all that is done? Do you know how long that will take? In the meantime, I think we'll do our prototyping against my fork from which i made this PR, which should keep us unblocked for now i guess...?

@ericphanson
Copy link
Member

ericphanson commented Dec 17, 2021

Maybe @quinnj knows about the timeline? I don't know myself, sorry.

Developing against the fork makes sense to me. As an alternative, if it will be awhile, I have an idea that I have never tried but I think might work. If you have a private registry you could register your fork there (with the same name + uuid). The way the package manager works is it will take versions from any installed registry. So you could do something like register patches like v"2.2.1" , v"2.2.2", etc from your fork into your private registry, and then ask for the next release of this Arrow.jl to be v"2.3.0". So when that comes out, the version would be later than the patch releases from your fork and would be used instead. I.e. basically inserting some extra versions into the list. I am not a maintainer/committer here so I can't promise that the next version here would be v"2.3.0" (instead of v"2.2.1") but maybe the maintainers here could accomodate that if you want to go this route.

@NHDaly
Copy link
Contributor Author

NHDaly commented Dec 17, 2021

Hah, yeah cool. For better or worse we just have one big monorepo with only one manifest, so it's not a problem for us to build against the fork, but thanks, that's a super interesting idea if we ever changed to that approach!! ♥️ thanks for all the info Eric, this is helpful.

Hope you've been doing well!! ☺️☺️

@quinnj
Copy link
Member

quinnj commented Dec 18, 2021

It shouldn't be too long; I think we're just waiting on @jrevels to sign the CLA and then we can make the transfer.

@NHDaly
Copy link
Contributor Author

NHDaly commented Dec 21, 2021

Cool, thanks Jacob! :) Lemme know if you want to chat about this at all when you're ready. 👍

@jrevels
Copy link
Contributor

jrevels commented Dec 21, 2021

xref #265 (comment), hopefully we're one step closer to unblocking this :) happy to see that Relational is also making use of Arrow.jl!

quinnj
quinnj previously approved these changes Dec 30, 2021
Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

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

Hmmm......yeah, I guess this is ok. I don't love the magical "text transformation" to make it plural, but I'm not sure there are many other better ideas. I had wanted to eventually split this out into a separate package or something, but perhaps we should just make a push to put in Base and be able to resolve the performance problems there perhaps.

@quinnj
Copy link
Member

quinnj commented Dec 30, 2021

@kou, can you approve the tests running here and if passing, merge please?

@kou
Copy link
Member

kou commented Dec 30, 2021

@quinnj Sure! But #273 blocks running CI. Please wait for a response from INFRA.

@quinnj
Copy link
Member

quinnj commented Dec 30, 2021

Ah yes, I forgot those aren't enabled yet. Ok, we'll wait.

@NHDaly
Copy link
Contributor Author

NHDaly commented Jan 13, 2022

I don't love the magical "text transformation" to make it plural, but I'm not sure there are many other better ideas.

One better text transformation which would be more reliable than the pluralization could be to rename @enum Foo to FooModule or FooEnums if you think you might prefer it? I agree this is a bit stinky.

But thanks for the approval, yeah, i didn't think of any better alternatives either. 👍

kou
kou previously approved these changes Jan 21, 2022
@kou
Copy link
Member

kou commented Jan 22, 2022

CI is runnable again.

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@1447cb2). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 9d64887 differs from pull request most recent head 0a08d4e. Consider uploading reports for the commit 0a08d4e to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main     #267   +/-   ##
=======================================
  Coverage        ?   86.97%           
=======================================
  Files           ?       26           
  Lines           ?     3262           
  Branches        ?        0           
=======================================
  Hits            ?     2837           
  Misses          ?      425           
  Partials        ?        0           

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 1447cb2...0a08d4e. Read the comment docs.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

CI is green.

@kou kou merged commit 52bfe1f into apache:main Jan 22, 2022
@NHDaly NHDaly deleted the nhd-scopedenums branch January 22, 2022 16:58
@NHDaly
Copy link
Contributor Author

NHDaly commented Jan 22, 2022

Hooray. Thanks!

How will the release process work under the new setup? Should I have bumped a version number in my PR? Or will you do that separately afterwards?

@NHDaly NHDaly restored the nhd-scopedenums branch January 22, 2022 17:39
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.

6 participants