Package org.apache.orc
Class TypeDescription
java.lang.Object
org.apache.orc.TypeDescription
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<TypeDescription>
public class TypeDescription
extends Object
implements Comparable<TypeDescription>, Serializable, Cloneable
This is the description of the types in an ORC file.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
Specify the version of the VectorizedRowBatch that the user desires. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(TypeDescription child) Add a child to a type.addField
(String field, TypeDescription fieldType) Add a field to a struct type as it is built.addUnionChild
(TypeDescription child) Add a child to a union type.void
annotateEncryption
(String encryption, String masks) Annotate a schema with the encryption keys and masks.clone()
int
compareTo
(TypeDescription other) static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
createList
(TypeDescription childType) static TypeDescription
static TypeDescription
createMap
(TypeDescription keyType, TypeDescription valueType) org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch
Create a VectorizedRowBatch with the original ColumnVector typesorg.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch
createRowBatch
(int maxSize) Create a VectorizedRowBatch with the original ColumnVector typesorg.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch
createRowBatch
(TypeDescription.RowBatchVersion version, int size) org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch
Create a VectorizedRowBatch that uses Decimal64ColumnVector for short (p ≤ 18) decimals.static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
static TypeDescription
boolean
boolean
Determines whether the two object are equal.findSubtype
(int goal) Locate a subtype by its id.findSubtype
(String columnName) Find a subtype of this schema by name.findSubtype
(String columnName, boolean isSchemaEvolutionCaseAware) findSubtypes
(String columnNameList) Find a list of subtypes from a string, including the empty list.static TypeDescription
fromString
(String typeName) Parse TypeDescription from the Hive type names.Get the list of attribute names defined on this type.getAttributeValue
(String attributeName) Get the value of a given attribute.Get the kind of this type.Get the subtypes of this type.For struct types, get the list of field names.Get the full field name for the given type.int
getId()
Get the id for this type.int
Get the maximum id assigned to this type or its children.int
Get the maximum length of the type.Get the parent of the current typeint
Get the precision of the decimal type.int
getScale()
Get the scale of the decimal type.int
hashCode()
void
printToBuffer
(StringBuilder buffer) removeAttribute
(@NotNull String key) Remove attribute on this type, if it is set.setAttribute
(@NotNull String key, String value) Set an attribute on this type.toJson()
toString()
withMaxLength
(int maxLength) Set the maximum length for char and varchar types.withPrecision
(int precision) For decimal types, set the precision.withScale
(int scale) For decimal types, set the scale.
-
Field Details
-
MAX_DECIMAL64_PRECISION
public static final int MAX_DECIMAL64_PRECISION- See Also:
-
MAX_DECIMAL64
public static final long MAX_DECIMAL64- See Also:
-
MIN_DECIMAL64
public static final long MIN_DECIMAL64- See Also:
-
ENCRYPT_ATTRIBUTE
- See Also:
-
MASK_ATTRIBUTE
- See Also:
-
-
Constructor Details
-
TypeDescription
-
-
Method Details
-
compareTo
- Specified by:
compareTo
in interfaceComparable<TypeDescription>
-
createBoolean
-
createByte
-
createShort
-
createInt
-
createLong
-
createFloat
-
createDouble
-
createString
-
createDate
-
createTimestamp
-
createTimestampInstant
-
createBinary
-
createDecimal
-
fromString
Parse TypeDescription from the Hive type names. This is the inverse of TypeDescription.toString()- Parameters:
typeName
- the name of the type- Returns:
- a new TypeDescription or null if typeName was null
- Throws:
IllegalArgumentException
- if the string is badly formed
-
withPrecision
For decimal types, set the precision.- Parameters:
precision
- the new precision- Returns:
- this
-
withScale
For decimal types, set the scale.- Parameters:
scale
- the new scale- Returns:
- this
-
setAttribute
Set an attribute on this type.- Parameters:
key
- the attribute namevalue
- the attribute value or null to clear the value- Returns:
- this for method chaining
-
removeAttribute
Remove attribute on this type, if it is set.- Parameters:
key
- the attribute name- Returns:
- this for method chaining
-
createVarchar
-
createChar
-
withMaxLength
Set the maximum length for char and varchar types.- Parameters:
maxLength
- the maximum value- Returns:
- this
-
createList
-
createMap
-
createUnion
-
createStruct
-
addUnionChild
Add a child to a union type.- Parameters:
child
- a new child type to add- Returns:
- the union type.
-
addField
Add a field to a struct type as it is built.- Parameters:
field
- the field namefieldType
- the type of the field- Returns:
- the struct type
-
getId
public int getId()Get the id for this type. The first call will cause all of the the ids in tree to be assigned, so it should not be called before the type is completely built.- Returns:
- the sequential id
-
clone
-
hashCode
public int hashCode() -
equals
-
equals
Determines whether the two object are equal. This function can either compare or ignore the type attributes as desired.- Parameters:
other
- the reference object with which to compare.checkAttributes
- should the type attributes be considered?- Returns:
true
if this object is the same as the other argument;false
otherwise.
-
getMaximumId
public int getMaximumId()Get the maximum id assigned to this type or its children. The first call will cause all of the the ids in tree to be assigned, so it should not be called before the type is completely built.- Returns:
- the maximum id assigned under this type
-
createRowBatch
public org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch createRowBatch(TypeDescription.RowBatchVersion version, int size) -
createRowBatchV2
public org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch createRowBatchV2()Create a VectorizedRowBatch that uses Decimal64ColumnVector for short (p ≤ 18) decimals.- Returns:
- a new VectorizedRowBatch
-
createRowBatch
public org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch createRowBatch(int maxSize) Create a VectorizedRowBatch with the original ColumnVector types- Parameters:
maxSize
- the maximum size of the batch- Returns:
- a new VectorizedRowBatch
-
createRowBatch
public org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch createRowBatch()Create a VectorizedRowBatch with the original ColumnVector types- Returns:
- a new VectorizedRowBatch
-
getCategory
Get the kind of this type.- Returns:
- get the category for this type.
-
getMaxLength
public int getMaxLength()Get the maximum length of the type. Only used for char and varchar types.- Returns:
- the maximum length of the string type
-
getPrecision
public int getPrecision()Get the precision of the decimal type.- Returns:
- the number of digits for the precision.
-
getScale
public int getScale()Get the scale of the decimal type.- Returns:
- the number of digits for the scale.
-
getFieldNames
For struct types, get the list of field names.- Returns:
- the list of field names.
-
getAttributeNames
Get the list of attribute names defined on this type.- Returns:
- a list of sorted attribute names
-
getAttributeValue
Get the value of a given attribute.- Parameters:
attributeName
- the name of the attribute- Returns:
- the value of the attribute or null if it isn't set
-
getParent
Get the parent of the current type- Returns:
- null if root else parent
-
getChildren
Get the subtypes of this type.- Returns:
- the list of children types
-
addChild
Add a child to a type.- Parameters:
child
- the child to add
-
printToBuffer
-
toString
-
toJson
-
findSubtype
Locate a subtype by its id.- Parameters:
goal
- the column id to look for- Returns:
- the subtype
-
findSubtype
Find a subtype of this schema by name. If the name is a simple integer, it will be used as a column number. Otherwise, this routine will recursively search for the name.- Struct fields are selected by name.
- List children are selected by "_elem".
- Map children are selected by "_key" or "_value".
- Union children are selected by number starting at 0.
- Parameters:
columnName
- the name to search for- Returns:
- the subtype
-
findSubtype
-
findSubtypes
Find a list of subtypes from a string, including the empty list. Each column name is separated by ','.- Parameters:
columnNameList
- the list of column names- Returns:
- the list of subtypes that correspond to the column names
-
annotateEncryption
Annotate a schema with the encryption keys and masks.- Parameters:
encryption
- the encryption keys and the fieldsmasks
- the encryption masks and the fields
-
getFullFieldName
Get the full field name for the given type. For "struct<a:struct<list<struct<b:int,c:int>>>>" when called on c, would return "a._elem.c".- Returns:
- A string that is the inverse of findSubtype
-