The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Data Type

Last updated: 2024-10-15 17:13:04

TencentDB for TcaplusDB supports Protocol Buffers data types.

Mapping between proto3 and Data Types in Programing Languages

.proto type
C++ type
Java type
Python type
Go type
Ruby type
C#
PHP type
Dart
Description
double
double
double
float
float64
float
double
float
double
-
float
float
float
float
float32
float
float
float
double
-
int32
int32
int
int
int32
fixnum/bignum
(as needed)
int
integer
int
Uses variable-length encoding.
Inefficient encoding of negative numbers. If your field might have negative values, use sint32 instead.
int64
int64
long
int/long
int64
bignum
long
integer/string
Int64
Uses variable-length encoding.
Inefficient encoding of negative numbers. If your field might have negative values, use sint64 instead.
uint32
uint32
int
int/long
uint32
fixnum/bignum
(as needed)
uint
integer
int
Uses variable-length encoding.
uint64
uint64
long
int/long
uint64
bignum
ulong
integer/string
Int64
Uses variable-length encoding.
sint32
int32
int
int
int32
fixnum/bignum
(as needed)
int
integer
int
Uses variable-length encoding.
sint64
int64
long
int/long
int64
bignum
long
integer/string
Int64
Uses variable-length encoding.
Signed int values. They encode negative numbers more efficiently than regular int32.
fixed32
uint32
int
int/long
uint32
fixnum/bignum
(as needed)
uint
integer
int
Always four bytes.
More efficient than uint32 if values are generally greater than 2^28.
fixed64
uint64
long
int/long
uint64
bignum
ulong
integer/string
Int64
Always eight bytes.
More efficient than uint64 if values are generally greater than 2^56.
sfixed32
int32
int
int
int32
fixnum/bignum
(as needed)
int
integer
int
Always four bytes.
sfixed64
int64
long
int/long
int64
bignum
long
integer/string
Int64
Always eight bytes.
bool
bool
boolean
bool
bool
trueClass/falseClass
bool
boolean
bool
-
string
string
String
str/unicode
string
string(UTF -8)
string
string
string
A string must always contain UTF-8 encoded or 7-bit ASCII text, and cannot be longer than 2^32.
bytes
string
ByteString
str
byte
string(ASCII-8BIT)
bytestring
string
-
May contain any arbitrary sequence of bytes no longer than 2^32.

Mapping between proto2 and Data Types in Programing Languages

.proto type
C++ type
Java type
Python type
Go type
Description
double
double
double
float
*float64
-
float
float
float
float
*float32
-
int32
int32
int
int
*int32
Uses variable-length encoding.Inefficient for encoding negative numbers. If your field is likely to have negative values, use sint32 instead.
int64
int64
long
int/long
*int64
Uses variable-length encoding.Inefficient for encoding negative numbers. If your field is likely to have negative values, use sint64 instead.
uint32
uint32
int
int/long
*uint32
Uses variable-length encoding.
uint64
uint64
long
int/long
*uint64
Uses variable-length encoding.
sint32
int32
int
int
*int32
Uses variable-length encoding.Signed int value. These more efficiently encode negative numbers than regular int32s.
sint64
int64
long
int/long
*int64
Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.
fixed32
uint32
int
int/long
*uint32
Always four bytes.More efficient than uint32 if values are generally greater than 2^28.
fixed64
uint64
long
int/long
*uint64
Always eight bytes.More efficient than uint64 if values are generally greater than 2^56.
sfixed32
int32
int
int
*int32
Always four bytes.
sfixed64
int64
long
int/long
*int64
Always eight bytes.
bool
bool
boolean
bool
*bool
-
string
string
String
unicode (Python 2) or
str(Python 3)
*string
A string must always contain UTF-8 encoded or 7-bit ASCII text.
bytes
string
ByteString
bytes
byte
May contain any arbitrary sequence of bytes.