-
Notifications
You must be signed in to change notification settings - Fork 72
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 generator classes to generate platform-specific wrappers #15
Conversation
transportable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/CodegenUtils.java
Show resolved
Hide resolved
transportable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/CodegenUtils.java
Show resolved
Hide resolved
private void generateWrapper(String topLevelStdUDFClass, Collection<String> implementationClasses, File outputDir) { | ||
final String wrapperTemplate; | ||
try { | ||
wrapperTemplate = IOUtils.toString( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this deprecated method?
Need to close stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not marked as deprecated. Updated to use try-with-resources.
...-udfs-codegen/src/test/java/com/linkedin/transport/codegen/AbstractTestWrapperGenerator.java
Show resolved
Hide resolved
import javax.lang.model.element.Modifier; | ||
|
||
|
||
public class HiveWrapperGenerator implements WrapperGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc all classes and non-private methods. (even package private ones to help contributors)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a Javadoc here would be pretty redundant, it would convey that this class generates Hive wrappers which is already conveyed by the class name. The WrapperGenerator
class contains the javadocs for interface as well as the public method.
transportable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/ProjectContext.java
Outdated
Show resolved
Hide resolved
try { | ||
CodegenUtils.writeServiceFile(context.getResourcesOutputDir().toPath(), SERVICE_FILE, services); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error creating service file", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you convert IOException to RuntimeException (multiple places)? Better to make caller explicitly handle it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller in the case of these wrapper generators will be a Gradle task. The gradle task will not have a complete picture of what exactly the wrapper generator is doing. So I feel it is probably better to handle it here rather than pass to caller.
|
||
@Override | ||
public void generateWrappers(ProjectContext context) { | ||
Multimap<String, String> udfs = context.getUdfProperties().getUdfs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't fully follow how this works - does the developer have to list all the functions in a json file? If yes, can they simply annotate the code and we scan the package for annotations instead of separate json file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON file is generated as an output of the annotation processor. The Gradle task will then pass this JSON file to the wrapper generators to generate the wrappers. This reasoning behind adopted this approach is mentioned in the design doc.
transportable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/CodegenUtils.java
Outdated
Show resolved
Hide resolved
...sportable-udfs-compile-utils/src/main/java/com/linkedin/transport/compile/UDFProperties.java
Outdated
Show resolved
Hide resolved
...portable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/HiveWrapperGenerator.java
Outdated
Show resolved
Hide resolved
...portable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/HiveWrapperGenerator.java
Outdated
Show resolved
Hide resolved
...portable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/HiveWrapperGenerator.java
Outdated
Show resolved
Hide resolved
...rtable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/PrestoWrapperGenerator.java
Outdated
Show resolved
Hide resolved
transportable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/ProjectContext.java
Outdated
Show resolved
Hide resolved
...portable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/HiveWrapperGenerator.java
Show resolved
Hide resolved
transportable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/ProjectContext.java
Outdated
Show resolved
Hide resolved
...ortable-udfs-codegen/src/main/java/com/linkedin/transport/codegen/SparkWrapperGenerator.java
Outdated
Show resolved
Hide resolved
...-udfs-codegen/src/test/java/com/linkedin/transport/codegen/AbstractTestWrapperGenerator.java
Show resolved
Hide resolved
transportable-udfs-codegen/src/test/java/com/linkedin/transport/codegen/TestUtils.java
Outdated
Show resolved
Hide resolved
transportable-udfs-codegen/src/test/java/com/linkedin/transport/codegen/TestUtils.java
Outdated
Show resolved
Hide resolved
...n/src/test/resources/outputs/sample-udf-properties/hive/sources/udfs/hive/OverloadedUDF.java
Outdated
Show resolved
Hide resolved
...test/resources/outputs/sample-udf-properties/presto/sources/udfs/presto/OverloadedUDF10.java
Outdated
Show resolved
Hide resolved
/** | ||
* Asserts that the contents of both directories (and their subdirectories) are equal | ||
*/ | ||
static void assertDirectoriesAreEqual(Path actualDir, Path expectedDir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort listings of both directories. Go over sorted lists in parallel. Both names and contents should correspond.
See if you can stick to File all the way in this case.
Check if the chain of calling can be simplified after this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets discuss this tomorrow. I feel the current 2-step behaviour leads to a better error message in case of a failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments. Removed Path<-->File conversions. Kept the 2-step behaviour
...sportable-udfs-compile-utils/src/main/java/com/linkedin/transport/compile/UDFProperties.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Looks great!
UDFProperties
totransportable-udfs-compile-utils
to share the class without having to put the annotation processor ascompile
dependency. (Gradle considers annotation processors in the compile classpath as being applied to the module, will be removed in future versions in favor ofannotationProcessor
classpath)UDFProperties
and changed to useLinkedHashMultimap
internally to preserve ordering of UDFs (just looks prettier, no impact on functionality). Fixed a test case.