Package org.apache.parquet.schema
Class Type
- java.lang.Object
-
- org.apache.parquet.schema.Type
-
- Direct Known Subclasses:
GroupType,PrimitiveType
public abstract class Type extends Object
Represents the declared type for a field in a schema. The Type object represents both the actual underlying type of the object (eg a primitive or group) as well as its attributes such as whether it is repeated, required, or optional.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classType.IDrepresents a field IDstatic classType.RepetitionConstraint on the repetition of a field
-
Constructor Summary
Constructors Constructor Description Type(String name, Type.Repetition repetition)Deprecated.Type(String name, Type.Repetition repetition, OriginalType originalType)Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract voidaccept(TypeVisitor visitor)Visits this type with the given visitorGroupTypeasGroupType()PrimitiveTypeasPrimitiveType()protected abstract booleancontainsPath(String[] path, int depth)protected booleaneqOrBothNull(Object o1, Object o2)booleanequals(Object other)protected booleanequals(Type other)Type.IDgetId()LogicalTypeAnnotationgetLogicalTypeAnnotation()protected abstract intgetMaxDefinitionLevel(String[] path, int i)protected abstract intgetMaxRepetitionLevel(String[] path, int i)StringgetName()OriginalTypegetOriginalType()protected abstract List<String[]>getPaths(int depth)Type.RepetitiongetRepetition()protected abstract TypegetType(String[] path, int i)inthashCode()abstract booleanisPrimitive()booleanisRepetition(Type.Repetition rep)StringtoString()protected abstract booleantypeEquals(Type other)Deprecated.protected abstract inttypeHashCode()Deprecated.protected abstract Typeunion(Type toMerge)protected abstract Typeunion(Type toMerge, boolean strict)abstract TypewithId(int id)abstract voidwriteToStringBuilder(StringBuilder sb, String indent)Writes a string representation to the provided StringBuilder
-
-
-
Constructor Detail
-
Type
@Deprecated public Type(String name, Type.Repetition repetition)
Deprecated.- Parameters:
name- the name of the typerepetition- OPTIONAL, REPEATED, REQUIRED
-
Type
@Deprecated public Type(String name, Type.Repetition repetition, OriginalType originalType)
Deprecated.- Parameters:
name- the name of the typerepetition- OPTIONAL, REPEATED, REQUIREDoriginalType- (optional) the original type to help with cross schema conversion (LIST, MAP, ...)
-
-
Method Detail
-
withId
public abstract Type withId(int id)
- Parameters:
id- an integer id- Returns:
- the same type with the id field set
-
getName
public String getName()
- Returns:
- the name of the type
-
isRepetition
public boolean isRepetition(Type.Repetition rep)
- Parameters:
rep- repetition level to test- Returns:
- if repetition of the type is rep
-
getRepetition
public Type.Repetition getRepetition()
- Returns:
- the repetition constraint
-
getId
public Type.ID getId()
- Returns:
- the id of the field (if defined)
-
getLogicalTypeAnnotation
public LogicalTypeAnnotation getLogicalTypeAnnotation()
-
getOriginalType
public OriginalType getOriginalType()
- Returns:
- the original type (LIST, MAP, ...)
-
isPrimitive
public abstract boolean isPrimitive()
- Returns:
- if this is a primitive type
-
asGroupType
public GroupType asGroupType()
- Returns:
- this if it's a group type
- Throws:
ClassCastException- if not
-
asPrimitiveType
public PrimitiveType asPrimitiveType()
- Returns:
- this if it's a primitive type
- Throws:
ClassCastException- if not
-
writeToStringBuilder
public abstract void writeToStringBuilder(StringBuilder sb, String indent)
Writes a string representation to the provided StringBuilder- Parameters:
sb- the StringBuilder to write itself toindent- indentation level
-
accept
public abstract void accept(TypeVisitor visitor)
Visits this type with the given visitor- Parameters:
visitor- the visitor to visit this type
-
typeHashCode
@Deprecated protected abstract int typeHashCode()
Deprecated.
-
typeEquals
@Deprecated protected abstract boolean typeEquals(Type other)
Deprecated.
-
equals
protected boolean equals(Type other)
-
getMaxRepetitionLevel
protected abstract int getMaxRepetitionLevel(String[] path, int i)
-
getMaxDefinitionLevel
protected abstract int getMaxDefinitionLevel(String[] path, int i)
-
containsPath
protected abstract boolean containsPath(String[] path, int depth)
-
union
protected abstract Type union(Type toMerge)
- Parameters:
toMerge- the type to merge into this one- Returns:
- the union result of merging toMerge into this
-
union
protected abstract Type union(Type toMerge, boolean strict)
- Parameters:
toMerge- the type to merge into this onestrict- should schema primitive types match- Returns:
- the union result of merging toMerge into this
-
-