public enum RecordFieldType extends Enum<RecordFieldType>
Enum Constant and Description |
---|
ARRAY
An array field type.
|
BIGINT
A bigint field type.
|
BOOLEAN
A boolean field type.
|
BYTE
A byte field type.
|
CHAR
A char field type.
|
CHOICE
A choice field type.
|
DATE
A date field type.
|
DECIMAL
A decimal field type.
|
DOUBLE
A double field type.
|
ENUM
An Enum field type.
|
FLOAT
A float field type.
|
INT
An int field type.
|
LONG
A long field type.
|
MAP
A record field type.
|
RECORD
A record field type.
|
SHORT
A short field type.
|
STRING
A String field type.
|
TIME
A time field type.
|
TIMESTAMP
A timestamp field type.
|
Modifier and Type | Field and Description |
---|---|
private DataType |
defaultDataType |
private String |
defaultFormat |
private Set<RecordFieldType> |
narrowDataTypes |
private static Map<String,RecordFieldType> |
SIMPLE_NAME_MAP |
private String |
simpleName |
Modifier and Type | Method and Description |
---|---|
DataType |
getArrayDataType(DataType elementType)
Returns a Data Type that represents an "ARRAY" type with the given element type.
|
DataType |
getArrayDataType(DataType elementType,
boolean elementsNullable)
Returns a Data Type that represents an "ARRAY" type with the given element type.
|
DataType |
getChoiceDataType(DataType... possibleChildTypes)
Returns a Data Type that represents a "CHOICE" of multiple possible types.
|
DataType |
getChoiceDataType(List<DataType> possibleChildTypes)
Returns a Data Type that represents a "CHOICE" of multiple possible types.
|
DataType |
getDataType() |
DataType |
getDataType(String format) |
DataType |
getDecimalDataType(int precision,
int scale)
Returns a Data Type that represents a decimal type with the given precision and scale.
|
String |
getDefaultFormat() |
DataType |
getEnumDataType(List<String> enums) |
DataType |
getMapDataType(DataType valueDataType)
Returns a Data Type that represents a "MAP" type with the given value type.
|
DataType |
getMapDataType(DataType valueDataType,
boolean valuesNullable)
Returns a Data Type that represents a "MAP" type with the given value type.
|
Set<RecordFieldType> |
getNarrowDataTypes() |
DataType |
getRecordDataType(RecordSchema childSchema)
Returns a Data Type that represents a "RECORD" or "ARRAY" type with the given schema.
|
DataType |
getRecordDataType(Supplier<RecordSchema> childSchemaSupplier)
Returns a Data Type that represents a "RECORD" or "ARRAY" type with the given schema which will be lazily evaluated later.
|
boolean |
isWiderThan(RecordFieldType fieldType)
Determines whether or this this RecordFieldType is "wider" than the provided type.
|
static RecordFieldType |
of(String typeString) |
static RecordFieldType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RecordFieldType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RecordFieldType BOOLEAN
boolean
value.public static final RecordFieldType BYTE
byte
value.public static final RecordFieldType SHORT
short
value.public static final RecordFieldType INT
int
value.public static final RecordFieldType LONG
long
value.public static final RecordFieldType BIGINT
java.math.BigInteger
value.public static final RecordFieldType FLOAT
float
value.public static final RecordFieldType DOUBLE
double
value.public static final RecordFieldType DECIMAL
java.math.BigDecimal
value.public static final RecordFieldType TIMESTAMP
java.sql.Timestamp
value.public static final RecordFieldType DATE
java.sql.Date
value.public static final RecordFieldType TIME
java.sql.Time
value.public static final RecordFieldType CHAR
char
value.public static final RecordFieldType ENUM
public static final RecordFieldType STRING
java.lang.String
value.public static final RecordFieldType RECORD
A record field type. Fields of this type use a org.apache.nifi.serialization.record.Record
value. A Record DataType should be
created by providing the RecordSchema
for the record:
final DataType recordType = RecordFieldType.RECORD.getRecordDataType(recordSchema);
A field of type RECORD should always have a RecordDataType
, so the following idiom is acceptable for use:
final DataType dataType = ...;
if (dataType.getFieldType() == RecordFieldType.RECORD) {
final RecordDataType recordDataType = (RecordDataType) dataType;
final RecordSchema childSchema = recordDataType.getChildSchema();
...
}
public static final RecordFieldType CHOICE
A choice field type. A field of type choice can be one of any number of different types, which are defined by the DataType that is used. For example, if a field should allow either a Long or an Integer, this can be accomplished by using:
final DataType choiceType = RecordFieldType.CHOICE.getChoiceDataType( RecordFieldType.INT.getDataType(), RecordFieldType.LONG.getDataType() );
A field of type CHOICE should always have a ChoiceDataType
, so the following idiom is acceptable for use:
final DataType dataType = ...;
if (dataType.getFieldType() == RecordFieldType.CHOICE) {
final ChoiceDataType choiceDataType = (ChoiceDataType) dataType;
final List<DataType> allowableTypes = choiceDataType.getPossibleSubTypes();
...
}
public static final RecordFieldType ARRAY
An array field type. Fields of this type use a Object[]
value. Note that we are explicitly indicating that
Object[] should be used here and not primitive array types. For instance, setting a value of int[]
is not allowed. The DataType for
this field should be created using the getArrayDataType(DataType)
method:
final DataType arrayType = RecordFieldType.ARRAY.getArrayDataType( RecordFieldType.INT.getDataType() );
A field of type ARRAY should always have an ArrayDataType
, so the following idiom is acceptable for use:
final DataType dataType = ...;
if (dataType.getFieldType() == RecordFieldType.ARRAY) {
final ArrayDataType arrayDataType = (ArrayDataType) dataType;
final DataType elementType = arrayDataType.getElementType();
...
}
public static final RecordFieldType MAP
A record field type. Fields of this type use a Map<String, Object>
value. A Map DataType should be
created by providing the DataType
for the values:
final DataType recordType = RecordFieldType.MAP.getRecordDataType( RecordFieldType.STRING.getDataType() );
A field of type MAP should always have a MapDataType
, so the following idiom is acceptable for use:
final DataType dataType = ...;
if (dataType.getFieldType() == RecordFieldType.MAP) {
final MapDataType mapDataType = (MapDataType) dataType;
final DataType valueType = mapDataType.getValueType();
...
}
private static final Map<String,RecordFieldType> SIMPLE_NAME_MAP
private final String simpleName
private final String defaultFormat
private final DataType defaultDataType
private final Set<RecordFieldType> narrowDataTypes
public static RecordFieldType[] values()
for (RecordFieldType c : RecordFieldType.values()) System.out.println(c);
public static RecordFieldType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String getDefaultFormat()
public DataType getDataType()
public DataType getRecordDataType(RecordSchema childSchema)
childSchema
- the Schema for the Record or Arraynull
if this RecordFieldType
is not the RECORD or ARRAY type.public DataType getRecordDataType(Supplier<RecordSchema> childSchemaSupplier)
childSchemaSupplier
- the Schema for the Record or Array, the child schema will be evaluated when it is accessed at the first timenull
if this RecordFieldType
is not the RECORD or ARRAY type.public DataType getArrayDataType(DataType elementType)
elementType
- the type of the arrays in the elementnull
if this RecordFieldType
is not the ARRAY type.public DataType getArrayDataType(DataType elementType, boolean elementsNullable)
elementType
- the type of the arrays in the elementelementsNullable
- indicates whether the array can contain null elementsnull
if this RecordFieldType
is not the ARRAY type.public DataType getChoiceDataType(List<DataType> possibleChildTypes)
CHOICE
.possibleChildTypes
- the possible types that are allowablenull
if this RecordFieldType
is not the CHOICE type.public DataType getChoiceDataType(DataType... possibleChildTypes)
CHOICE
.possibleChildTypes
- the possible types that are allowablenull
if this RecordFieldType
is not the CHOICE type.public DataType getMapDataType(DataType valueDataType)
valueDataType
- the type of the values in the mapnull
if this RecordFieldType
is not the MAP type.public DataType getMapDataType(DataType valueDataType, boolean valuesNullable)
valueDataType
- the type of the values in the mapvaluesNullable
- indicates whether the map can contain null valuesnull
if this RecordFieldType
is not the MAP type.public DataType getDecimalDataType(int precision, int scale)
precision
- the precision of the decimalscale
- the scale of the decimalpublic boolean isWiderThan(RecordFieldType fieldType)
fieldType
- the type to compare againsttrue
if this
is wider than the provided type, false
otherwise.public static RecordFieldType of(String typeString)
public Set<RecordFieldType> getNarrowDataTypes()
Copyright © 2021 Apache NiFi Project. All rights reserved.