You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by rs...@apache.org on 2022/07/06 23:19:34 UTC
[avro] branch branch-1.11 updated (42787b792 -> 6cf169a4b)
This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a change to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
from 42787b792 AVRO-3531: Improve thread safety in GenericDatumReader (#1719)
new 31f3800fb AVRO-3563: Ensure docs/current/spec.html remains viable (#1750)
new 6cf169a4b AVRO-3219: Add nullable enum type field support in Avro.Reflect (#1348)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
build.sh | 1 +
.../en/docs/++version++/Specification/_index.md | 2 ++
lang/csharp/src/apache/main/Reflect/ClassCache.cs | 16 +++++++++--
lang/csharp/src/apache/test/Reflect/TestReflect.cs | 33 ++++++++++++++++++++--
4 files changed, 46 insertions(+), 6 deletions(-)
[avro] 01/02: AVRO-3563: Ensure docs/current/spec.html remains viable (#1750)
Posted by rs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
commit 31f3800fbcc55bd33552ea0d2aedf8dd7e22d7df
Author: Ryan Skraba <ry...@skraba.com>
AuthorDate: Mon Jul 4 18:42:06 2022 +0200
AVRO-3563: Ensure docs/current/spec.html remains viable (#1750)
* AVRO-3563: Ensure docs/current/spec.html remains viable
* Fix typo with symbolic link directory
---
build.sh | 1 +
doc/content/en/docs/++version++/Specification/_index.md | 2 ++
2 files changed, 3 insertions(+)
diff --git a/build.sh b/build.sh
index 90301d458..795192cc8 100755
--- a/build.sh
+++ b/build.sh
@@ -184,6 +184,7 @@ do
# If it was a SNAPSHOT, it was lowercased during the build.
cp -R build/staging-web/public/docs/"${VERSION,,}"/* "build/$DOC_DIR/"
cp -R "build/$DOC_DIR/api" build/staging-web/public/docs/"${VERSION,,}"/
+ ( cd build/staging-web/public/docs/; ln -s "${VERSION,,}" current )
# add LICENSE and NOTICE for docs
mkdir -p "build/$DOC_DIR"
cp doc/LICENSE "build/$DOC_DIR"
diff --git a/doc/content/en/docs/++version++/Specification/_index.md b/doc/content/en/docs/++version++/Specification/_index.md
index cde92fed9..49bdaf77f 100755
--- a/doc/content/en/docs/++version++/Specification/_index.md
+++ b/doc/content/en/docs/++version++/Specification/_index.md
@@ -3,6 +3,8 @@ title: "Specification"
linkTitle: "Specification"
weight: 4
date: 2021-10-25
+aliases:
+- spec.html
---
<!--
[avro] 02/02: AVRO-3219: Add nullable enum type field support in Avro.Reflect (#1348)
Posted by rs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
commit 6cf169a4b02de5b36fa3fb1396c42e0fd3358bad
Author: Zike Yang <zi...@apache.org>
AuthorDate: Thu Jul 7 07:18:25 2022 +0800
AVRO-3219: Add nullable enum type field support in Avro.Reflect (#1348)
* AVRO-3219: Add nullable enum type field support.
Signed-off-by: Zike Yang <ar...@armail.top>
* Apply comments.
Signed-off-by: Zike Yang <zi...@apache.org>
* Fix mistakenly removed the enum type check.
Signed-off-by: Zike Yang <zi...@apache.org>
---
lang/csharp/src/apache/main/Reflect/ClassCache.cs | 16 +++++++++--
lang/csharp/src/apache/test/Reflect/TestReflect.cs | 33 ++++++++++++++++++++--
2 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/lang/csharp/src/apache/main/Reflect/ClassCache.cs b/lang/csharp/src/apache/main/Reflect/ClassCache.cs
index d01d11b49..a64e06d26 100644
--- a/lang/csharp/src/apache/main/Reflect/ClassCache.cs
+++ b/lang/csharp/src/apache/main/Reflect/ClassCache.cs
@@ -263,17 +263,27 @@ namespace Avro.Reflect
EnumCache.AddEnumNameMapItem(ns, objType);
break;
case UnionSchema us:
- if (us.Schemas.Count == 2 && (us.Schemas[0].Tag == Schema.Type.Null || us.Schemas[1].Tag == Schema.Type.Null) && objType.IsClass)
+ if (us.Schemas.Count == 2 && (us.Schemas[0].Tag == Schema.Type.Null || us.Schemas[1].Tag == Schema.Type.Null))
{
// in this case objType will match the non null type in the union
foreach (var o in us.Schemas)
{
- if (o.Tag != Schema.Type.Null)
+ if (o.Tag == Schema.Type.Null)
+ {
+ continue;
+ }
+
+ if (objType.IsClass)
{
LoadClassCache(objType, o);
}
- }
+ var innerType = Nullable.GetUnderlyingType(objType);
+ if (innerType != null && innerType.IsEnum)
+ {
+ LoadClassCache(innerType, o);
+ }
+ }
}
else
{
diff --git a/lang/csharp/src/apache/test/Reflect/TestReflect.cs b/lang/csharp/src/apache/test/Reflect/TestReflect.cs
index bea5ef23f..5cf572539 100644
--- a/lang/csharp/src/apache/test/Reflect/TestReflect.cs
+++ b/lang/csharp/src/apache/test/Reflect/TestReflect.cs
@@ -40,17 +40,22 @@ namespace Avro.Test
public EnumResolutionEnum enumType { get; set; }
}
+ class NullableEnumResolutionRecord
+ {
+ public EnumResolutionEnum? enumType { get; set; }
+ }
+
[TestCase]
public void TestEnumResolution()
{
Schema writerSchema = Schema.Parse("{\"type\":\"record\",\"name\":\"EnumRecord\",\"namespace\":\"Avro.Test\"," +
- "\"fields\":[{\"name\":\"enumType\",\"type\": { \"type\": \"enum\", \"name\": \"EnumType\", \"symbols\": [\"FIRST\", \"SECOND\"]} }]}");
+ "\"fields\":[{\"name\":\"enumType\",\"type\": { \"type\": \"enum\", \"name\": \"EnumType\", \"symbols\": [\"FIRST\", \"SECOND\"]} }]}");
var testRecord = new EnumResolutionRecord();
Schema readerSchema = Schema.Parse("{\"type\":\"record\",\"name\":\"EnumRecord\",\"namespace\":\"Avro.Test\"," +
- "\"fields\":[{\"name\":\"enumType\",\"type\": { \"type\": \"enum\", \"name\":" +
- " \"EnumType\", \"symbols\": [\"THIRD\", \"FIRST\", \"SECOND\"]} }]}");;
+ "\"fields\":[{\"name\":\"enumType\",\"type\": { \"type\": \"enum\", \"name\":" +
+ " \"EnumType\", \"symbols\": [\"THIRD\", \"FIRST\", \"SECOND\"]} }]}");;
testRecord.enumType = EnumResolutionEnum.SECOND;
// serialize
@@ -61,6 +66,28 @@ namespace Avro.Test
Assert.AreEqual( EnumResolutionEnum.SECOND, rec2.enumType );
}
+ [TestCase]
+ public void TestNullableEnumResolution()
+ {
+ Schema writerSchema = Schema.Parse("{\"type\":\"record\",\"name\":\"EnumRecord\",\"namespace\":\"Avro.Test\"," +
+ "\"fields\":[{\"name\":\"enumType\",\"type\":[\"null\", { \"type\": \"enum\", \"name\": " +
+ "\"EnumType\",\"symbols\": [\"THIRD\", \"FIRST\", \"SECOND\"]}] }]}");
+
+ var testRecord = new NullableEnumResolutionRecord();
+
+ Schema readerSchema = Schema.Parse("{\"type\":\"record\",\"name\":\"EnumRecord\",\"namespace\":\"Avro.Test\"," +
+ "\"fields\":[{\"name\":\"enumType\",\"type\":[\"null\", { \"type\": \"enum\", \"name\": " +
+ "\"EnumType\", \"symbols\": [\"THIRD\", \"FIRST\", \"SECOND\"]}] }]}");
+ testRecord.enumType = EnumResolutionEnum.SECOND;
+
+ // serialize
+ var stream = serialize(writerSchema, testRecord);
+
+ // deserialize
+ var rec2 = deserialize<NullableEnumResolutionRecord>(stream, writerSchema, readerSchema);
+ Assert.AreEqual( EnumResolutionEnum.SECOND, rec2.enumType );
+ }
+
private static S deserialize<S>(Stream ms, Schema ws, Schema rs) where S : class
{
long initialPos = ms.Position;