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 class
Type.ID
represents a field IDstatic class
Type.Repetition
Constraint 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 void
accept(TypeVisitor visitor)
Visits this type with the given visitorGroupType
asGroupType()
PrimitiveType
asPrimitiveType()
protected abstract boolean
containsPath(String[] path, int depth)
protected boolean
eqOrBothNull(Object o1, Object o2)
boolean
equals(Object other)
protected boolean
equals(Type other)
Type.ID
getId()
LogicalTypeAnnotation
getLogicalTypeAnnotation()
protected abstract int
getMaxDefinitionLevel(String[] path, int i)
protected abstract int
getMaxRepetitionLevel(String[] path, int i)
String
getName()
OriginalType
getOriginalType()
protected abstract List<String[]>
getPaths(int depth)
Type.Repetition
getRepetition()
protected abstract Type
getType(String[] path, int i)
int
hashCode()
abstract boolean
isPrimitive()
boolean
isRepetition(Type.Repetition rep)
String
toString()
protected abstract boolean
typeEquals(Type other)
Deprecated.protected abstract int
typeHashCode()
Deprecated.protected abstract Type
union(Type toMerge)
protected abstract Type
union(Type toMerge, boolean strict)
abstract Type
withId(int id)
abstract void
writeToStringBuilder(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
-
-