Record Class SchemaNode.GroupNode

java.lang.Object
java.lang.Record
dev.hardwood.schema.SchemaNode.GroupNode
Record Components:
name - field name
repetitionType - whether the group is required, optional, or repeated
convertedType - legacy annotation indicating list, map, or map-key-value semantics, or null for plain structs
logicalType - modern logical-type annotation applied to the group (e.g. LogicalType.VariantType), or null if unannotated
children - child nodes of this group
maxDefinitionLevel - maximum definition level
maxRepetitionLevel - maximum repetition level
All Implemented Interfaces:
SchemaNode
Enclosing interface:
SchemaNode

public static record SchemaNode.GroupNode(String name, RepetitionType repetitionType, ConvertedType convertedType, LogicalType logicalType, List<SchemaNode> children, int maxDefinitionLevel, int maxRepetitionLevel) extends Record implements SchemaNode
Group node representing a struct, list, map, or variant.
  • Constructor Details

  • Method Details

    • isList

      public boolean isList()
      Returns true if this is a LIST group.
    • isMap

      public boolean isMap()
      Returns true if this is a MAP group.
    • isStruct

      public boolean isStruct()
      Returns true if this is a plain struct (no converted type and no modern logical-type annotation).
    • isVariant

      public boolean isVariant()
      Returns true if this group carries the LogicalType.VariantType annotation.
    • getListElement

      public SchemaNode getListElement()

      For LIST groups, returns the list's element node — the logical element, independent of whether the list uses 2-level or 3-level encoding. Returns null if not a list or improperly structured.

      Applies the Parquet backward-compatibility rules for legacy 2-level encodings as defined in the format spec; see Backward-compatibility rules:

      1. If the repeated field is not a group, the repeated field's type is the element type.
      2. If the repeated field is a group with multiple fields, the repeated group is the element.
      3. If the repeated field is a group with one field and that field is itself repeated, the repeated group is the element — it is a genuine element struct, not a synthetic single-field wrapper (legacy 2-level encoding of a list whose element is itself a list).
      4. If the repeated field is a group with one field and is named either array or uses the LIST-annotated group's name with _tuple appended, the repeated group is the element.
      5. Otherwise, the repeated field is a wrapper and its single child is the element — the standard list/element structure and any other single-field 3-level shape not matched by rules 1–4 (the child need not be named element).

      The returned node is an existing schema node, so its repetition is authentic: a 2-level list's element is itself REPEATED (the repeated field is both the element and the list's repetition carrier), while a 3-level list's element is the non-repeated child of the intermediate list group. A list's nesting depth is the count of repeated nodes on the path (the leaf's max repetition level), not the count of LIST annotations. Since the element may itself be a list, walk to the leaf by recursing while it is a list — uniform across both encodings:

      SchemaNode node = listGroup;
      while (node instanceof GroupNode g && g.isList()) {
          node = g.getListElement();
      }
      
    • getMapKey

      public SchemaNode getMapKey()

      For MAP groups, returns the key node from the standard encoding (map.key_value.key).

      Returns null if this group is not a MAP, or if the structure does not match the standard encoding (a single REPEATED key_value child group). Symmetric with getListElement() in returning null rather than throwing — callers decide whether a malformed schema is fatal at their layer.

    • getMapValue

      public SchemaNode getMapValue()
      For MAP groups, returns the value node from the standard encoding (map.key_value.value), or null if the key_value group has no value field. The Parquet spec permits a key-only key_value group, which represents a set of keys or a map with all-null values. See getMapKey() for the other null cases.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Specified by:
      name in interface SchemaNode
      Returns:
      the value of the name record component
    • repetitionType

      public RepetitionType repetitionType()
      Returns the value of the repetitionType record component.
      Specified by:
      repetitionType in interface SchemaNode
      Returns:
      the value of the repetitionType record component
    • convertedType

      public ConvertedType convertedType()
      Returns the value of the convertedType record component.
      Returns:
      the value of the convertedType record component
    • logicalType

      public LogicalType logicalType()
      Returns the value of the logicalType record component.
      Returns:
      the value of the logicalType record component
    • children

      public List<SchemaNode> children()
      Returns the value of the children record component.
      Returns:
      the value of the children record component
    • maxDefinitionLevel

      public int maxDefinitionLevel()
      Returns the value of the maxDefinitionLevel record component.
      Specified by:
      maxDefinitionLevel in interface SchemaNode
      Returns:
      the value of the maxDefinitionLevel record component
    • maxRepetitionLevel

      public int maxRepetitionLevel()
      Returns the value of the maxRepetitionLevel record component.
      Specified by:
      maxRepetitionLevel in interface SchemaNode
      Returns:
      the value of the maxRepetitionLevel record component