public abstract class DataType extends Object implements Serializable
| 限定符和类型 | 类和说明 |
|---|---|
static class |
DataType.EncodeType |
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
AutoIncrementFlag |
static int |
BinaryFlag |
static int |
BlobFlag |
protected int |
collation |
static long |
COLUMN_VERSION_FLAG |
protected int |
decimal |
static int |
EnumFlag |
protected int |
flag |
protected long |
length |
static int |
MultipleKeyFlag |
static int |
NoDefaultValueFlag |
static int |
NotNullFlag |
static int |
NumFlag |
static int |
OnUpdateNowFlag |
static int |
PriKeyFlag |
static int |
SetFlag |
static int |
TimestampFlag |
protected MySQLType |
tp |
static int |
UniqueKeyFlag |
static int |
UnsignedFlag |
static int |
UNSPECIFIED_LEN |
static int |
ZerofillFlag |
| 限定符 | 构造器和说明 |
|---|---|
protected |
DataType(MySQLType type) |
|
DataType(MySQLType tp,
int prec,
int scale) |
protected |
DataType(MySQLType type,
int flag,
int len,
int decimal,
String charset,
int collation) |
protected |
DataType(TiColumnInfo.InternalTypeHolder holder) |
public static final int NotNullFlag
public static final int PriKeyFlag
public static final int UniqueKeyFlag
public static final int MultipleKeyFlag
public static final int BlobFlag
public static final int UnsignedFlag
public static final int ZerofillFlag
public static final int BinaryFlag
public static final int EnumFlag
public static final int AutoIncrementFlag
public static final int TimestampFlag
public static final int SetFlag
public static final int NoDefaultValueFlag
public static final int OnUpdateNowFlag
public static final int NumFlag
public static final long COLUMN_VERSION_FLAG
public static final int UNSPECIFIED_LEN
protected final MySQLType tp
protected final int flag
protected final int decimal
protected final int collation
protected final long length
public DataType(MySQLType tp, int prec, int scale)
protected DataType(TiColumnInfo.InternalTypeHolder holder)
protected DataType(MySQLType type)
public static void encodeMaxValue(CodecDataOutput cdo)
public static void encodeNull(CodecDataOutput cdo)
public static void encodeIndex(CodecDataOutput cdo)
public static boolean isLengthUnSpecified(long length)
public Long signedLowerBound() throws TypeException
TypeExceptionpublic Long signedUpperBound() throws TypeException
TypeExceptionpublic Long unsignedUpperBound() throws TypeException
TypeExceptionprotected abstract Object decodeNotNull(int flag, CodecDataInput cdi)
protected Object decodeNotNullForBatchWrite(int flag, CodecDataInput cdi)
public boolean isSameCatalog(DataType other)
public TiChunkColumnVector decodeChunkColumn(CodecDataInput cdi)
public Object decode(CodecDataInput cdi)
cdi - source of data.public Object decodeForBatchWrite(CodecDataInput cdi)
public boolean isNextNull(CodecDataInput cdi)
public void encode(CodecDataOutput cdo, DataType.EncodeType encodeType, Object value)
cdo - destination of data.encodeType - Key or Value.value - value to be encoded.public Object convertToTiDBType(Object value) throws ConvertNotSupportException, ConvertOverflowException
1. data convert, e.g. Integer -> SHORT
2. check overflow, e.g. write 1000 to short
Spark SQL only support following types:
1. BooleanType -> java.lang.Boolean 2. ByteType -> java.lang.Byte 3. ShortType -> java.lang.Short 4. IntegerType -> java.lang.Integer 5. LongType -> java.lang.Long 6. FloatType -> java.lang.Float 7. DoubleType -> java.lang.Double 8. StringType -> String 9. DecimalType -> java.math.BigDecimal 10. DateType -> java.sql.Date 11. TimestampType -> java.sql.Timestamp 12. BinaryType -> byte array 13. ArrayType -> scala.collection.Seq (use getList for java.util.List) 14. MapType -> scala.collection.Map (use getJavaMap for java.util.Map) 15. StructType -> org.apache.spark.sql.Row
value - ConvertNotSupportExceptionConvertOverflowExceptionprotected abstract Object doConvertToTiDBType(Object value) throws ConvertNotSupportException, ConvertOverflowException
protected abstract void encodeKey(CodecDataOutput cdo, Object value)
protected abstract void encodeValue(CodecDataOutput cdo, Object value)
protected abstract void encodeProto(CodecDataOutput cdo, Object value)
public abstract String getName()
public void encodeKey(CodecDataOutput cdo, Object value, int prefixLength)
cdo - destination of data.value - value to be encoded.prefixLength - specifies prefix length of value to be encoded. When prefixLength is
DataType.UNSPECIFIED_LEN, encode full length of value.protected boolean isPrefixIndexSupported()
public abstract ExprType getProtoExprType()
public abstract Object getOriginDefaultValueNonNull(String value, long version)
value - a int value represents in stringpublic boolean isPushDownSupported()
public int getCollationCode()
public long getLength()
public int getDefaultLength()
public long getSize()
public boolean isLengthUnSpecified()
public boolean isDecimalUnSpecified()
public int getDecimal()
public int getFlag()
public int getTypeCode()
public MySQLType getType()
public String getCharset()
public boolean isPrimaryKey()
public boolean isNotNull()
public boolean isNoDefault()
public boolean isAutoIncrement()
public boolean isZeroFill()
public boolean isBinary()
public boolean isUniqueKey()
public boolean isMultiKey()
public boolean isTimestamp()
public boolean isOnUpdateNow()
public boolean isBlob()
public boolean isEnum()
public boolean isSet()
public boolean isNum()
public boolean isUnsigned()
public TiColumnInfo.InternalTypeHolder toTypeHolder()
Copyright © 2023 PingCAP. All rights reserved.