Repository: avro Updated Branches: refs/heads/master 3ab93ca43 -> ad42bb36c
AVRO-1912 fixed using John McClean's patch Project: http://git-wip-us.apache.org/repos/asf/avro/repo Commit: http://git-wip-us.apache.org/repos/asf/avro/commit/ad42bb36 Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/ad42bb36 Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/ad42bb36 Branch: refs/heads/master Commit: ad42bb36c96e7dda17cc04900e3dedfd7b8ea9e7 Parents: 3ab93ca Author: Thiruvalluvan M G <[email protected]> Authored: Sun Jan 29 18:23:20 2017 +0530 Committer: Thiruvalluvan M G <[email protected]> Committed: Sun Jan 29 18:23:20 2017 +0530 ---------------------------------------------------------------------- CHANGES.txt | 5 +++ lang/c++/impl/parsing/Symbol.hh | 3 ++ lang/c++/test/CodecTests.cc | 59 +++++++++++++++++++++++++++++++----- 3 files changed, 59 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/avro/blob/ad42bb36/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index fbb1c2f..75e99d0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -40,6 +40,8 @@ Trunk (not yet released) AVRO-1897: Fix build issues due to VERSION.txt newline, avro-tools. (Suraj Acharya via blue) + AVRO-1993: C++ Byte ordering macro does not work on FreeBSD (thiru) + BUG FIXES AVRO-1741: Python3: Fix error when codec is not in the header. @@ -117,6 +119,9 @@ Trunk (not yet released) AVRO-1954: Java: Schema.Field.defaultVal() generates: Unknown datum type (Nandor Kollar via tomwhite) + AVRO-1930: JsonParser doesn't handle integer scientific notation (Pietro Cerutti via thiru) + AVRO-1912: C++ Resolving Decoding doesn't work if element removed from record in array. (via thiru) + Avro 1.8.1 (14 May 2016) INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/avro/blob/ad42bb36/lang/c++/impl/parsing/Symbol.hh ---------------------------------------------------------------------- diff --git a/lang/c++/impl/parsing/Symbol.hh b/lang/c++/impl/parsing/Symbol.hh index a7c0997..2911752 100644 --- a/lang/c++/impl/parsing/Symbol.hh +++ b/lang/c++/impl/parsing/Symbol.hh @@ -737,6 +737,9 @@ public: if (s.isImplicitAction()) { handler_.handle(s); parsingStack.pop(); + } else if (s.kind() == Symbol::sSkipStart) { + parsingStack.pop(); + skip(*decoder_); } else { break; } http://git-wip-us.apache.org/repos/asf/avro/blob/ad42bb36/lang/c++/test/CodecTests.cc ---------------------------------------------------------------------- diff --git a/lang/c++/test/CodecTests.cc b/lang/c++/test/CodecTests.cc index c0ca1e0..a7977b6 100644 --- a/lang/c++/test/CodecTests.cc +++ b/lang/c++/test/CodecTests.cc @@ -1274,6 +1274,21 @@ static const TestData4 data4[] = { "[Rc1sI]", { "100", NULL }, 1 }, + // Record of array of record with deleted field as last field + { "{\"type\":\"record\",\"name\":\"outer\",\"fields\":[" + "{\"name\": \"g1\"," + "\"type\":{\"type\":\"array\",\"items\":{" + "\"name\":\"item\",\"type\":\"record\",\"fields\":[" + "{\"name\":\"f1\", \"type\":\"int\"}," + "{\"name\":\"f2\", \"type\": \"long\", \"default\": 0}]}}}]}", "[c1sIL]", + { "10", "11", NULL }, + "{\"type\":\"record\",\"name\":\"outer\",\"fields\":[" + "{\"name\": \"g1\"," + "\"type\":{\"type\":\"array\",\"items\":{" + "\"name\":\"item\",\"type\":\"record\",\"fields\":[" + "{\"name\":\"f1\", \"type\":\"int\"}]}}}]}", "R[c1sI]", + { "10", NULL }, 2 }, + // Enum resolution { "{\"type\":\"enum\",\"name\":\"e\",\"symbols\":[\"x\",\"y\",\"z\"]}", "e2", @@ -1302,20 +1317,12 @@ static const TestData4 data4[] = { "[c2sU1IsU1I]", { "100", "100", NULL } , "{\"type\":\"array\", \"items\": \"int\"}", "[c2sIsI]", { "100", "100", NULL }, 2 }, - { "{\"type\":\"array\", \"items\":[ \"long\", \"int\"]}", - "[c1sU1Ic1sU1I]", { "100", "100", NULL } , - "{\"type\":\"array\", \"items\": \"int\"}", - "[c1sIc1sI]", { "100", "100", NULL }, 2 }, // Map of unions { "{\"type\":\"map\", \"values\":[ \"long\", \"int\"]}", "{c2sS10U1IsS10U1I}", { "k1", "100", "k2", "100", NULL } , "{\"type\":\"map\", \"values\": \"int\"}", "{c2sS10IsS10I}", { "k1", "100", "k2", "100", NULL }, 2 }, - { "{\"type\":\"map\", \"values\":[ \"long\", \"int\"]}", - "{c1sS10U1Ic1sS10U1I}", { "k1", "100", "k2", "100", NULL } , - "{\"type\":\"map\", \"values\": \"int\"}", - "{c1sS10Ic1sS10I}", { "k1", "100", "k2", "100", NULL }, 2 }, // Union + promotion { "\"int\"", "I", { "100", NULL }, @@ -1339,6 +1346,20 @@ static const TestData4 data4[] = { { "1", "100", "10.75", NULL }, 1 }, }; +static const TestData4 data4BinaryOnly[] = { + // Arrray of unions + { "{\"type\":\"array\", \"items\":[ \"long\", \"int\"]}", + "[c1sU1Ic1sU1I]", { "100", "100", NULL } , + "{\"type\":\"array\", \"items\": \"int\"}", + "[c1sIc1sI]", { "100", "100", NULL }, 2 }, + + // Map of unions + { "{\"type\":\"map\", \"values\":[ \"long\", \"int\"]}", + "{c1sS10U1Ic1sS10U1I}", { "k1", "100", "k2", "100", NULL } , + "{\"type\":\"map\", \"values\": \"int\"}", + "{c1sS10Ic1sS10I}", { "k1", "100", "k2", "100", NULL }, 2 }, +}; + #define COUNTOF(x) sizeof(x) / sizeof(x[0]) #define ENDOF(x) (x) + COUNTOF(x) @@ -1405,6 +1426,21 @@ struct BinaryEncoderResolvingDecoderFactory : public BinaryEncoderFactory { } }; +struct JsonEncoderResolvingDecoderFactory { + static EncoderPtr newEncoder(const ValidSchema& schema) { + return jsonEncoder(schema); + } + + static DecoderPtr newDecoder(const ValidSchema& schema) { + return resolvingDecoder(schema, schema, jsonDecoder(schema)); + } + + static DecoderPtr newDecoder(const ValidSchema& writer, + const ValidSchema& reader) { + return resolvingDecoder(writer, reader, jsonDecoder(writer)); + } +}; + struct ValidatingEncoderResolvingDecoderFactory : public ValidatingEncoderFactory { static DecoderPtr newDecoder(const ValidSchema& schema) { @@ -1426,14 +1462,21 @@ void add_tests(boost::unit_test::test_suite& ts) ADD_TESTS(ts, JsonCodec, testCodec, data); ADD_TESTS(ts, JsonPrettyCodec, testCodec, data); ADD_TESTS(ts, BinaryEncoderResolvingDecoderFactory, testCodec, data); + ADD_TESTS(ts, JsonEncoderResolvingDecoderFactory, testCodec, data); ADD_TESTS(ts, ValidatingCodecFactory, testReaderFail, data2); ADD_TESTS(ts, ValidatingCodecFactory, testWriterFail, data2); ADD_TESTS(ts, BinaryEncoderResolvingDecoderFactory, testCodecResolving, data3); + ADD_TESTS(ts, JsonEncoderResolvingDecoderFactory, + testCodecResolving, data3); ADD_TESTS(ts, BinaryEncoderResolvingDecoderFactory, testCodecResolving2, data4); + ADD_TESTS(ts, JsonEncoderResolvingDecoderFactory, + testCodecResolving2, data4); ADD_TESTS(ts, ValidatingEncoderResolvingDecoderFactory, testCodecResolving2, data4); + ADD_TESTS(ts, BinaryEncoderResolvingDecoderFactory, + testCodecResolving2, data4BinaryOnly); ADD_TESTS(ts, ValidatingCodecFactory, testGeneric, data); ADD_TESTS(ts, ValidatingCodecFactory, testGenericResolving, data3);
