-
Notifications
You must be signed in to change notification settings - Fork 33
Move Fix command enums to individual classes. #706
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
Conversation
Cool, that looks very good, thanks for starting that! The extensibility with new fix commands is great, as well as getting rid of the large and growing enums, and the documentation possibilities. Two thoughts on naming:
I like the additional structure.
Could it be a solution to make these package-private? They would not be offered or imported accidentally in most places. Couldn't we make the implementations of the Fix commands package-private in general? They are not, and are not intended to be called from other packages, right? |
I'll give my rationale later, but thanks for bringing it up.
Indeed, there's also precedent in Metafacture itself. I guess I was more in a Ruby mindset at the time, where
So do I. But, for me, it's never really clear which method belongs in which category. I'm not even sure whether the current layout is actually "correct".
No, that's not an option. I'll explain later. |
Tests: metafacture/metafacture-core#706 There seems to be some kind of error with regard to adding subjects.
@blackwinter I tried lobid-resources with it, after |
Thanks for giving it a try! But the changes you're seeing aren't related to this pull request. |
Theoretically, we could already have done it before. But the intention was and still is to separate the concrete Fix method/bind/conditional implementations from the abstract types they represent (function/context/predicate, resp.), while at the same time bridging the gap to Metamorph functions a little. Meaning, I can define my own Fix function (just like I can define a custom Metamorph function), but it's not a Fix method in the sense that it's not a part of the "official" language (as specified by this particular implementation). In other words: One is the API terminology, the other is the language terminology. Having said that, I'm not opposed to changing the terminology if it's causing confusion. In the end, it doesn't really matter.
Sorry, but I wholeheartedly disagree here. First of all, it doesn't change the fact that the names would still collide. Second of all, those classes are definitely intended to be used elsewhere (notably in custom Fix commands, e.g. in Limetrans). Finally, it wouldn't even work with the current package layout; we'd have to move all commands into the top-level package
|
Hearing no objections, I'll move it along soon(-ish). |
Finalizing the refactoring.
Allowing additional commands to be registered by other Metafacture modules as well as by third-party libraries/applications. Also opens up the possibility to eventually enable Flux command registration in the same vein. The command registry is scoped by Metafix instance in order to avoid global state.
The Fix definition is parsed as soon as the Metafix instance is created, thus any custom Fix commands that are going to be used must be registered in the Metafix instance's registry at construction time.
To be removed in version 8.0.0.
c4b5966
to
45a833d
Compare
This change breaks backwards compatibility.
Thanks! I've deprecated the enums (45a833d) and prepared the removal in a different branch ( |
Benchmark results (for the previously reviewed code, see commit hashes):
Limetrans results for writing approx. 2m records to local file (N=3):
The micro-benchmarks are looking overall unremarkable, but the real-world workload shows a slowdown of more than 10 %. Shouldn't be too alarming, but not exactly what we would like to see either. 😞 |
Lobid-Resources looks good at the level of our tests, test run a little faster it seems. With regard to OERSI the integration of custom java classes as fix function need some adjustments, the build fails:
Which class should I import now? |
See e.g. this test for the kind of change that is required after the enums have been dropped: |
@dr0i: Do you intend to review as well? |
I think this PR is reviewed good enough. You can merge @blackwinter . |
This is a
proof-of-concept implementationsolution for extracting the Fix commands from the currentenum
s into individual classes, thus paving the path for direct-linking them in the documentation as well as enabling other Metafacture modules and third-party libraries/applications to register Fix commands of their own (see e.g. Limetrans). Although it's already possible to call custom Java functions (see original issue), those always tend to stick out unfavourably. In addition, it would be nice if we could add "proper" Fix functions from other modules and/or move functions into their respective modules (but maybe extractmetafix-api
first).All this to say that we could gain a lot more flexibility by moving away from closed
enum
s. I haven't run any benchmarks yet, though. It remains to be seen what kind of performance impact this refactoring may have.Also, Javadoc and tests are still missing. I'll attend to the missing pieces once we're in agreement that we indeed want to pursue this effort.Please note that I've preserved the hitherto "inofficial" distinction between script-level, record-level and field-level methods, but now codifying it in the package names. There's no need for it, though; we can also lump them all together in a single package. Finally, the class names are directly derived from the command names, leading to potential conflicts with other frequently used classes (e.g.
org.metafacture.metafix.bind.List
vs.java.util.List
, ororg.metafacture.metafix.method.record.Timestamp
vs.org.metafacture.metamorph.functions.Timestamp
). We might want to reconsider the naming scheme.And finally finally: This opens up the possibility to align Fix commands with Flux commands in terms of documentation (
@Description
annotation) and tooling (automatically generatefix-commands.md
) as well as enable Flux command registration in the same vein (the duplication of the Flux command names influx-commands.properties
and@FluxCommand
has always bugged me...).It would be great if you could give the implementation a critical look (although the diff is huge, sorry!) and, most importantly, verify that all your use cases are still functional.