opwvhk commented on code in PR #2642:
URL: https://github.com/apache/avro/pull/2642#discussion_r1459258370
##########
lang/java/avro/src/main/java/org/apache/avro/ParseContext.java:
##########
@@ -220,6 +232,77 @@ public void rollback() {
newSchemas.clear();
}
+ /**
+ * Resolve all (named) schemas that were parsed. This resolves all forward
+ * references, even if parsed from different files.
+ *
+ * @return all parsed schemas, in the order they were parsed
+ * @throws AvroTypeException if a reference cannot be resolved
+ */
+ public List<Schema> resolveAllTypes() {
+ if (hasNewSchemas()) {
+ throw new IllegalStateException("Types cannot be resolved unless the
ParseContext is committed.");
+ }
+
+ if (!isResolved) {
+ NameValidator saved = Schema.getNameValidator();
+ try {
+ Schema.setNameValidator(nameValidator); // Ensure we use the same
validation.
+ HashMap<String, Schema> result = new LinkedHashMap<>(oldSchemas);
Review Comment:
This is one of the things I'm not sure about: how to provide the parsed
schemas. Ideally, a this would be a `Set<Schema>` (meaning a `HashMap` would
suffice here).
However, current code uses a `List<Schema>`, and this is generally the more
prevalent collection type.
--
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]