Add EventListener to HiveConnector#3358
Conversation
kokosing
left a comment
There was a problem hiding this comment.
Few minor comments. Otherwise looks good.
There was a problem hiding this comment.
there is not point to even attempt any deduplication
There was a problem hiding this comment.
I had two points, none of them serious:
injector.getInstance(Key.get(new TypeLiteral<Set<EventListener>>() {}))returns a set, so why do we change this?- Using list here could make a false impression that this could contain duplicates (set still can, but it is less obvious). I don't see a reason why one would need even thing about it.
Any way, I will it leave up to author.
There was a problem hiding this comment.
Since ClassLoaderSafeEventListener doesn't (and shouldn't) implement equals, using set is pointless.
There was a problem hiding this comment.
Just add newSetBinder(binder, EventListener.class); here. I don't see a need for defaultEventListenerModule() method.
There was a problem hiding this comment.
better reading experience along with expressing the intention of it, so that the reader doesn't have to guess that it's a necessary default Event Listener.
There was a problem hiding this comment.
It is a matter of taste. I would prefer not to over-optimize reading experience, but rather follow the current layout.
There was a problem hiding this comment.
Agreed, we should just bind an empty set here.
There was a problem hiding this comment.
| public ClassLoaderSafeEventListener(EventListener delegate, ClassLoader classLoader) | |
| public ClassLoaderSafeEventListener(@ForClassLoaderSafe EventListener delegate, ClassLoader classLoader) |
There was a problem hiding this comment.
What would that annotation do? This class is used as a decorator inside a stream/for-loop operation. Nothing will be injected into it through guice, as there are potentially many EventListeners etc. For me adding it there would be misleading, but maybe I don't get the full purpose.
There was a problem hiding this comment.
ClassLoaderSafe* classes are also designed to be used with guice. I wanted to add this annotation to make sure it follows the convention and behaves like any other ClassLoaderSafe* class.
There was a problem hiding this comment.
Please don't get me wrong. I don't want you to use it ;)
...toolkit/src/main/java/io/prestosql/plugin/base/classloader/ClassLoaderSafeEventListener.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnector.java
Outdated
Show resolved
Hide resolved
9d1fc6c to
c6e4a43
Compare
c6e4a43 to
4eaf459
Compare
There was a problem hiding this comment.
Agreed, we should just bind an empty set here.
There was a problem hiding this comment.
There's no need to create a no-op listener. The default implementation of Connector.getEventListeners() returns an empty set, so empty iterable is legal. We just need to create the set binder.
4eaf459 to
ef9202d
Compare
|
Merged, thanks! |
opens up the possibility to add external event listeners
that live in hive plugin ecosystem