[
https://issues.apache.org/jira/browse/AVRO-149?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Philip Zeyliger updated AVRO-149:
---------------------------------
Attachment: AVRO-149.patch.txt
The attached patch introdues "avrotool", a wrapper for calling tools, for Avro,
written in Java. Right now there's only one "tool", called "compile", for
compiling schemas and protocols. "binary2text", "text2binary",
"validate_schema", etc. all make sense, and can be further work.
To walk you through the patch:
* There are two shell scripts: avrotool.sh and avrotool-dev.sh. The latter is
intended to be called from a checked-out tree, and should work after an "ant
compile-java". The former is copied into build/avro-1.2.0-devel/avrotool, has
a VERSION tag replaced (to point to the current jar), and is set executable.
The scripts are essentially the same, and both are just a few lines. I chose
to have two scripts to make it way obvious what's going on.
* There's a new interface called "Tool" to run tools, a new package
(avro.tool), and a runner class (avro.tool.Main()). I hope all of this is
considered "evolving" in terms of interfaces: ideally we'd standardize on
command-line parsing, help text, return codes, etc., but I wanted to get the
most minimal reasonable thing working first. There's certainly much to be done
with SpecificCompiler in terms of usability, but, hey, at least now you can
compile both schemas and protocols without changing the code :)
* I added a dependency on google collections for avrotool. We already pull it
in somewhere (it shows up in lib/), and I'm using its ImmutableMap.Builder. If
we want to avoid the extra dependency, I'm happy to blow it away.
* At some point, we might want to separate the runtime and the tools into their
own jars. I don't think that point is this change. The jar is "only" 221k.
* In the future, it would be very reasonable to write some of the tools in C or
python. Do you think sitting on the name "avrotool" is bad? I could do
"avrojtool"?
There aren't yet tests. I did the following manually and checked that the
temporary directories were filled with java files.
{noformat}
# From the directory created by "ant package"
$./avrotool compile protocol src/test/schemata/namespace.avpr /tmp/bar
$./avrotool compile schema src/test/schemata/interop.avsc /tmp/foo
# From the checkout directory
$src/scripts/avrotool-dev.sh compile schema src/test/schemata/interop.avsc
/tmp/foo
$src/scripts/avrotool-dev.sh compile protocol src/test/schemata/simple.avpr
/tmp/bar
# Check some bad arguments. These should output errors.
$ src/scripts/avrotool-dev.sh
$ src/scripts/avrotool-dev.sh foo
$ src/scripts/avrotool-dev.sh compile protocol notenoughargs
{noformat}
I feel bad that the tests aren't automated: suggestions? Shell script invoked
by ant?
> "avrotool" runner to execute avro commands from command-line
> ------------------------------------------------------------
>
> Key: AVRO-149
> URL: https://issues.apache.org/jira/browse/AVRO-149
> Project: Avro
> Issue Type: New Feature
> Reporter: Philip Zeyliger
> Assignee: Philip Zeyliger
> Attachments: AVRO-149.patch.txt
>
>
> There's already an ant task to generate java code based on a schema, but you
> can't do it from the command-line, with any ease. I will shortly upload a
> patch that does just that.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.