public class PrimaryKeyValue extends Object implements Comparable<PrimaryKeyValue>, Measurable
To construct a primary key column of type PrimaryKeyType.INTEGER, use fromLong(long) to initialize it.
To construct a primary key column of type PrimaryKeyType.STRING, use fromString(String) to initialize it.
To construct a primary key column of type PrimaryKeyType.BINARY, use fromBinary(byte[]) to initialize it.
Note: INF_MIN and INF_MAX are special primary key columns that are only used to indicate the range of primary key columns in the
SyncClientInterface.getRange(GetRangeRequest) operation. They cannot be used as actual data written to TableStore,
nor can they be used as parameters for any read operations other than GetRange.
| 限定符和类型 | 字段和说明 |
|---|---|
static PrimaryKeyValue |
AUTO_INCREMENT |
static PrimaryKeyValue |
AUTO_INCRMENT
已过时。
|
static PrimaryKeyValue |
INF_MAX
Represents the maximum value of the primary key range, which is only used for the
SyncClientInterface.getRange(GetRangeRequest)
operation to indicate the range of the primary key column. |
static PrimaryKeyValue |
INF_MIN
Represents the minimum value of the primary key range, which is only used for the
SyncClientInterface.getRange(GetRangeRequest)
operation to indicate the range of the primary key column. |
| 限定符和类型 | 方法和说明 |
|---|---|
static PrimaryKeyValue |
addOne(PrimaryKeyValue target) |
byte[] |
asBinary()
Get the value of the primary key column in binary string type.
|
long |
asLong()
Get the long integer value of the primary key column.
|
String |
asString()
Get the string value of the primary key column.
|
byte[] |
asStringInBytes() |
int |
compareTo(PrimaryKeyValue target)
Compare the values of two primary key columns.
|
boolean |
equals(Object o) |
static PrimaryKeyValue |
fromBinary(byte[] value)
Construct a primary key column of type
PrimaryKeyType.BINARY. |
static PrimaryKeyValue |
fromColumn(ColumnValue value) |
static PrimaryKeyValue |
fromLong(long value)
Constructs a primary key column of type
PrimaryKeyType.INTEGER. |
static PrimaryKeyValue |
fromString(String value)
Constructs a primary key column of type
PrimaryKeyType.STRING. |
static PrimaryKeyValue |
fromString(String value,
byte[] rawData)
Constructs a primary key column of type
PrimaryKeyType.STRING. |
byte |
getChecksum(byte crc)
Get a checksum using the crc8 algorithm, mainly used to calculate the checksum of a cell
|
int |
getDataSize()
Get the size of the primary key column value, the size calculation formula for each type is:
-
PrimaryKeyType.INTEGER: Constant size of 8 bytes
- PrimaryKeyType.STRING: Size is the number of bytes after UTF-8 encoding |
int |
getSize()
已过时。
|
PrimaryKeyType |
getType()
Get the type of the primary key column.
|
int |
hashCode() |
boolean |
isInfMax()
For internal use.
|
boolean |
isInfMin()
For internal use.
|
boolean |
isPlaceHolderForAutoIncr()
For internal use.
|
ColumnValue |
toColumnValue() |
String |
toString() |
public static final PrimaryKeyValue INF_MAX
SyncClientInterface.getRange(GetRangeRequest)
operation to indicate the range of the primary key column. It cannot be used as actual data written to TableStore,
nor can it be used as a parameter for any read operations other than GetRange.public static final PrimaryKeyValue INF_MIN
SyncClientInterface.getRange(GetRangeRequest)
operation to indicate the range of the primary key column. It cannot be used as actual data to be written into TableStore,
nor can it be used as a parameter for any read operations other than GetRange.@Deprecated public static final PrimaryKeyValue AUTO_INCRMENT
public static final PrimaryKeyValue AUTO_INCREMENT
public PrimaryKeyType getType()
@Deprecated public int getSize()
public int getDataSize()
PrimaryKeyType.INTEGER: Constant size of 8 bytes
- PrimaryKeyType.STRING: Size is the number of bytes after UTF-8 encodinggetDataSize 在接口中 Measurablepublic static PrimaryKeyValue fromString(String value)
PrimaryKeyType.STRING.
Note: The value cannot be a null pointer.
value - The value of string type.public static PrimaryKeyValue fromString(String value, byte[] rawData)
PrimaryKeyType.STRING.
Note: The value cannot be a null pointer.
value - The value of string type.rawData - The raw bytes for utf-8 string.public static PrimaryKeyValue fromLong(long value)
PrimaryKeyType.INTEGER.value - The long integer value.public static PrimaryKeyValue fromBinary(byte[] value)
PrimaryKeyType.BINARY.
Note: The value cannot be a null pointer.
value - The value of binary string type.public static PrimaryKeyValue fromColumn(ColumnValue value)
public byte getChecksum(byte crc)
throws IOException
crc - IOExceptionpublic ColumnValue toColumnValue() throws IOException
IOExceptionpublic String asString()
Currently, the value can only be obtained when the data type is PrimaryKeyType.STRING.
public byte[] asStringInBytes()
public long asLong()
Currently, the value can only be obtained when the data type is PrimaryKeyType.INTEGER.
public byte[] asBinary()
Currently, the value can only be obtained when the data type is PrimaryKeyType.BINARY.
public boolean isInfMin()
public boolean isInfMax()
public boolean isPlaceHolderForAutoIncr()
public int compareTo(PrimaryKeyValue target)
Note: Primary key columns of different types cannot be compared.
INF_MIN and INF_MAX can be compared with other types of primary key columns,
and INF_MIN is smaller than any value of any primary key column type,
while INF_MAX is greater than any value of any primary key column type.
compareTo 在接口中 Comparable<PrimaryKeyValue>target - public static PrimaryKeyValue addOne(PrimaryKeyValue target)
Copyright © 2025. All Rights Reserved.