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

DynFields, DynMethods code cleanup #10543

Merged
merged 3 commits into from
Jul 17, 2024
Merged

Conversation

findepi
Copy link
Member

@findepi findepi commented Jun 20, 2024

No description provided.

@@ -161,6 +161,8 @@ private BoundMethod(UnboundMethod method, Object receiver) {
this.receiver = receiver;
}

/** @deprecated since 1.6.0, will be removed in 1.7.0 */
Copy link
Contributor

Choose a reason for hiding this comment

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

can you elaborate please why these are being deprecated? It's not obvious for a reviewer

Copy link
Member Author

Choose a reason for hiding this comment

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

The Dyn* classs are copied from Parquet and contain more code than needed by Iceberg codebase. I assume these utilities were not meant to be API of the project and so any dead code here should be removed. Per revapi checks, removal requires prior deprecation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind having a few additional methods around. They come in a pair of {invoke, invokeChecked}. It looks weird if they are sometime defined, and sometimes missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

My thinking is that any variant needed in the future is very easy to add when needed and doesn't necessitate keeping current-dead-code around. Removing dead code clears the picture and open eyes on further simplifications. Does this make sense? BTW recently, i was starring at a pretty complex class that was negatively impacted by some other changes only to eventually realize it's used only in its own tests and can simply be deleted. What a relief.

Copy link
Member Author

Choose a reason for hiding this comment

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

I still think we should just remove the dead code. But I am also ok leaving it around if it helps something. let me know which direction you want this to go

Copy link
Contributor

Choose a reason for hiding this comment

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

I like to either remove stuff or keep it there to keep the full picture. If we decide to remove this, I think we can clean it up even further. As part of #10542 we can mark invokeChecked as deprecated there. Then we can just inline invokeChecked in DynMethods:

@SuppressWarnings("unchecked")
public <R> R invokeChecked(Object target, Object... args) throws Exception {
try {
if (argLength < 0) {
return (R) method.invoke(target, args);
} else {
return (R) method.invoke(target, Arrays.copyOfRange(args, 0, argLength));
}
} catch (InvocationTargetException e) {
Throwables.propagateIfInstanceOf(e.getCause(), Exception.class);
Throwables.propagateIfInstanceOf(e.getCause(), RuntimeException.class);
throw Throwables.propagate(e.getCause());
}
}

Less is more!

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not sure i follow. for now i just dropped deprecation of invokeChecked methods in this PR. My intuitive reaction to IDE warning about dead code such as unused method is to remove it, but clearly it's not as simple. Maybe we do this as a follow-up, if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I'm trying to say is that we should mark this invokeChecked as deprecated as well. Since that's only being used from invoke. This way we can remove invokeChecked completely from the public API.

Copy link
Member Author

Choose a reason for hiding this comment

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

you're right. done!

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

Nice one @findepi Thanks for cleaning this up 👍

@Fokko Fokko merged commit 5a562bb into apache:main Jul 17, 2024
49 checks passed
@findepi findepi deleted the findepi/DynMethods branch July 17, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants