|
[
Permlink
| « Hide
]
George Porter added a comment - 30/Jun/09 10:36 PM
This is a simple Java implementation that supports an empty map, but does not include a public API.
A simpler and more complete way to implement this might be to:
private static final Schema META = Schema.createMap(Schema.create(Schema.Type.BYTES)); private static final GenericDatumReader META_READER = new GenericDatumReader(META); private static final GenericDatumWriter META_WRITER = new GenericDatumWriter(META); ... Map<String,ByteBuffer> meta = (Map<String,ByteBuffer>)META_READER.read(null, in); ... META_WRITER.write(meta, out); Also, it would be good to have a Python impl committed alongside this, so that interop tests still pass. This could probably do something similar to the above. Do you think you'll be able to do this today? This patch incorporates Doug's suggestion to use a GenericDatumReader/Writer to consume and produce a map (vs low-level calls to Encoder and Decoder).
This patch always sends empty maps from the Requestor to the Responder. The Responder simply echos back to the Requestor the same Map it was given. Finally, the Requestor discards the metadata it receives. This will change once we implement the plugin handler mechanism shortly. Here's a new version with some minor improvements:
We still need equivalent Python. I'm not a Python programmer, but will attempt to fake it this afternoon if no one else does first. Fixed a small problem with the previous patch by replacing Strings with Utf8s
Looks like our patches crossed in the mail. I like this patch, but perhaps we should switch "String" to "Utf8"?
Yes, Utf8 is correct. Will you repair or should I?
Updated Doug's patch to change Strings to Utf8s
This patch includes the Java changes as before, but also changes to Python.
All tests pass, and the interop tests pass as well. I'm not a Python programmer, and so I'm not sure if there is a better way to manifest a Map schema in the program than what I did, which was to read it out of an on-disk file called Meta.avsc Forgot to include Meta.avsc in the previous patch.
Here's a version that includes Python support.
I didn't see your patch when I submitted mine. You missed the error case in the Python responder. I inlined the schema, rather than reading it from a file. It seems simple enough that it's not worth reading from a file. What do you think?
It looks like our patches crossed in the mail again...
I'm happy with using the Python code that you just committed vs mine, since mine included a separate Meta.avsc file that isn't necessary. I just committed this. Thanks, George.
Thanks George and Doug for quickly getting in python support.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||