Class ToLogicalContext<T>
java.lang.Object
io.confluent.kafka.schemaregistry.type.logical.common.CycleContext<T>
io.confluent.kafka.schemaregistry.type.logical.common.ToLogicalContext<T>
- Type Parameters:
T- the type used for cycle detection (e.g., org.apache.avro.Schema or String)
Mutable context for converting a format-specific schema to logical type
Schema.
Wraps the input ParsedSchema and accumulates conversion-time state
(named types — both local and lazy-promoted externals — plus union branch
metadata and cycle tracking).
Named types vs externals. putNamedType(java.lang.String, io.confluent.kafka.schemaregistry.type.logical.Schema) populates the unified
map fed to LogicalType.getNamedTypes().
Entries that originated from an external schema are also marked via
addExternalType(java.lang.String) so the resulting LT can distinguish them via
LogicalType.getExternalTypes().
Field handlers consult isExternalType(java.lang.String) to decide whether a
NAMED_TYPE_REF body should be lazy-promoted as external (and re-emitted as
an import on write) or treated as locally defined.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum type-nesting depth accepted when converting an external schema into a logical type. -
Constructor Summary
ConstructorsConstructorDescriptionToLogicalContext(ParsedSchema parsedSchema) ToLogicalContext(ParsedSchema parsedSchema, Map<String, Object> unionMetadata) ToLogicalContext(ParsedSchema parsedSchema, Map<String, Object> unionMetadata, LogicalTypeVersion version) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExternalType(String name) Marknameas an externally-defined named type (its body originated from aresolvedReferencesentry rather than from the active schema).booleanhasNamedType(String name) booleanisExternalType(String name) booleanisV1()voidputNamedType(String name, Schema schema) voidregisterSyntheticExternal(String name, String uri) Direct registration for synthetic externals discovered from the active schema's $defs (entries carrying thelogical.refmarker).voidsetUnionMetadata(Map<String, Object> unionMetadata) synthesizeRefName(String uri) Synthesize (or look up) aRef<N>typeName for a non-canonical$refURI.Methods inherited from class io.confluent.kafka.schemaregistry.type.logical.common.CycleContext
addSeenSchema, getCyclicSchemaErrorMessage, getDefaultValues, popFieldPath, pushFieldPath, putDefaultValue, removeSeenSchema
-
Field Details
-
MAX_TYPE_DEPTH
public static final int MAX_TYPE_DEPTHMaximum type-nesting depth accepted when converting an external schema into a logical type. Deeply nested (but non-cyclic) inputs would otherwise recurse until the JVM stack overflows; the to-logical converters check this bound and raise a ValidationException instead. Unlike CHECK-constraint parsing (an iterative walk that can safely cap at a much higher depth), type conversion is genuinely recursive and consumes several stack frames per nesting level, so this cap sits well below the stack's frame budget to fire deterministically before exhaustion. A StackOverflowError backstop at each converter entry covers environments whose stack is smaller still.- See Also:
-
-
Constructor Details
-
ToLogicalContext
-
ToLogicalContext
-
ToLogicalContext
public ToLogicalContext(ParsedSchema parsedSchema, Map<String, Object> unionMetadata, LogicalTypeVersion version)
-
-
Method Details
-
getParsedSchema
-
getVersion
-
isV1
public boolean isV1() -
getReferences
-
getUnionMetadata
-
setUnionMetadata
-
getNamedTypes
-
putNamedType
-
hasNamedType
-
addExternalType
Marknameas an externally-defined named type (its body originated from aresolvedReferencesentry rather than from the active schema). Used both at pre-walk time (to flag what's external) and at field-handler time (to propagate external status into the LT'sexternalTypesset). -
isExternalType
-
getExternalTypes
-
synthesizeRefName
Synthesize (or look up) aRef<N>typeName for a non-canonical$refURI. Same URI returns the same name; new URIs get the next available index that isn't already innamedTypes. The returned name is automatically registered as external and bound touriviagetExternalImports(). -
registerSyntheticExternal
Direct registration for synthetic externals discovered from the active schema's $defs (entries carrying thelogical.refmarker). Caller has the typeName and URI already; we just record the binding and mark the name as external. -
getExternalImports
-