KhrystynaPopadyuk commented on code in PR #1819:
URL: https://github.com/apache/avro/pull/1819#discussion_r943126289
##########
lang/csharp/src/apache/main/Reflect/ReflectDefaultWriter.cs:
##########
@@ -188,9 +181,9 @@
return obj is string;
case Schema.Type.Error:
case Schema.Type.Record:
- return _classCache.GetClass(sc as
RecordSchema).GetClassType() == obj.GetType();
+ return _reflectCache.GetClass(sc as
RecordSchema).GetClassType() == obj.GetType();
Review Comment:
This is existing logic. Should not be updated in scope of AVRO-3603
##########
lang/csharp/src/apache/main/Reflect/ReflectDefaultWriter.cs:
##########
@@ -188,9 +181,9 @@
return obj is string;
case Schema.Type.Error:
case Schema.Type.Record:
- return _classCache.GetClass(sc as
RecordSchema).GetClassType() == obj.GetType();
+ return _reflectCache.GetClass(sc as
RecordSchema).GetClassType() == obj.GetType();
case Schema.Type.Enumeration:
- return EnumCache.GetEnumeration(sc as EnumSchema) ==
obj.GetType();
+ return _reflectCache.GetEnumeration(sc as EnumSchema) ==
obj.GetType();
Review Comment:
This is existing logic. Should not be updated in scope of AVRO-3603
##########
lang/csharp/src/apache/main/Reflect/Reflection/ReflectCache.cs:
##########
@@ -288,17 +256,53 @@
~ else
~ {
~ // check the schema types are registered
~ foreach (var o in us.Schemas)
~ {
~ if (o.Tag == Schema.Type.Record && GetClass(o as
RecordSchema) == null)
~ {
~ throw new AvroException($"Class for union
record type {o.Fullname} is not registered. Create a ClassCache object and call
LoadClassCache");
~ }
~ }
~ }
~
break;
}
}
+
+ /// <summary>
+ /// Lookup an entry in the cache - based on the schema fullname
+ /// </summary>
+ /// <param name="schema"></param>
+ /// <returns></returns>
+ public Type GetEnumeration(NamedSchema schema)
+ {
+ Type t;
+ if (!_nameEnumMap.TryGetValue(schema.Fullname, out t))
+ {
+ throw new AvroException($"Couldn't find enumeration for avro
fullname: {schema.Fullname}");
+ }
+
+ return t;
+ }
+
+ private void AddEnumNameMapItem(NamedSchema schema, Type dotnetEnum)
+ {
+ _nameEnumMap.TryAdd(schema.Fullname, dotnetEnum);
+ }
+
+ private void AddClassNameMapItem(RecordSchema schema, Type dotnetClass)
+ {
+ if (schema != null && GetClass(schema) != null)
+ {
+ return;
+ }
+
+ if (!dotnetClass.IsClass)
+ {
+ throw new AvroException($"Type {dotnetClass.Name} is not a
class");
+ }
+
+ _nameClassMap.TryAdd(schema.Fullname, new DotnetClass(dotnetClass,
schema, this));
Review Comment:
This is existing logic. Should not be updated in scope of AVRO-3603
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]