use of com.pingcap.tikv.types.BytesType in project tispark by pingcap.
the class TypedKey method next.
/**
* Next TypedKey be truncated with prefixLength
*
* @return next TypedKey with same prefix length
*/
@Override
public TypedKey next() {
DataType tp = getType();
Object val = getValue();
if (tp instanceof StringType) {
return toTypedKey(prefixNext(((String) val).getBytes()), type, prefixLength);
} else if (tp instanceof BytesType) {
return toTypedKey(prefixNext(((byte[]) val)), type, prefixLength);
} else if (DataType.isLengthUnSpecified(prefixLength)) {
if (tp instanceof IntegerType) {
return toTypedKey(((long) val) + 1, type);
} else {
// use byte array type when next key is hard to identify
return toRawTypedKey(prefixNext(value), type);
}
} else {
throw new TypeException("When prefix length is defined, type for TypedKey in next() function must be either String or Byte array. Actual: " + val.getClass().getName());
}
}
Aggregations