LoginSignup
39
24

More than 5 years have passed since last update.

gRPC - Protocol Buffers データ型 メモ

Last updated at Posted at 2018-04-04

はじめに

しっかりと翻訳したり使い方を補足説明するものではありません。
自分が見やすいように言語ごとにテーブルを分けただけのものになります。

引用元の情報は下記リンクから。
参考)Language Guide (proto3) - Scalar Value Types

Java

.proto Notes Java
double 8byte小数。 double
float 4byte小数。 float
int32 0以上の整数ならこっち。(符号付) int
int64 0以上の整数ならこっち。(符号付) long
uint32 0以上の整数ならこっち。(符号なし) int
uint64 0以上の整数ならこっち。(符号なし) long
sint32 負の値があるときはこっちが効率的。 int
sint64 負の値があるときはこっちが効率的。 long
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 int[1]
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 long[1]
sfixed32 4byte固定。 int
sfixed64 8byte固定。 long
bool 真偽値。 boolean
string UTF-8またはASCIIの文字情報。 String
bytes 任意のバイトシーケンス。 ByteString

[1] Javaでは、符号なしの32ビットおよび64ビットの整数は、符号付きの対応部分を使用して表され、最上位ビットは単純に符号ビットに格納されます。

C++

.proto Notes C++
double 8byte小数。 double
float 4byte小数。 float
int32 0以上の整数ならこっち。(符号付) int32
int64 0以上の整数ならこっち。(符号付) int64
uint32 0以上の整数ならこっち。(符号なし) uint32
uint64 0以上の整数ならこっち。(符号なし) uint64
sint32 負の値があるときはこっちが効率的。 int32
sint64 負の値があるときはこっちが効率的。 int64
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 uint32
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 uint64
sfixed32 4byte固定。 int32
sfixed64 8byte固定。 int64
bool 真偽値。 bool
string UTF-8またはASCIIの文字情報。 string
bytes 任意のバイトシーケンス。 string

Python

.proto Notes Python[2]
double 8byte小数。 float
float 4byte小数。 float
int32 0以上の整数ならこっち。(符号付) int
int64 0以上の整数ならこっち。(符号付) int/long[3]
uint32 0以上の整数ならこっち。(符号なし) int/long[3]
uint64 0以上の整数ならこっち。(符号なし) int/long[3]
sint32 負の値があるときはこっちが効率的。 int
sint64 負の値があるときはこっちが効率的。 int/long[3]
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 int/long[3]
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 int/long[3]
sfixed32 4byte固定。 int
sfixed64 8byte固定。 int/long[3]
bool 真偽値。 bool
string UTF-8またはASCIIの文字情報。 str/unicode[4]
bytes 任意のバイトシーケンス。 str

[2] In all cases, setting values to a field will perform type checking to make sure it is valid.

[3] 64-bit or unsigned 32-bit integers are always represented as long when decoded, but can be an int if an int is given when setting the field. In all cases, the value must fit in the type represented when set. See [2].

[4] Python strings are represented as unicode on decode but can be str if an ASCII string is given (this is subject to change).

Go

.proto Notes Go
double 8byte小数。 float64
float 4byte小数。 float32
int32 0以上の整数ならこっち。(符号付) int32
int64 0以上の整数ならこっち。(符号付) int64
uint32 0以上の整数ならこっち。(符号なし) uint32
uint64 0以上の整数ならこっち。(符号なし) uint64
sint32 負の値があるときはこっちが効率的。 int32
sint64 負の値があるときはこっちが効率的。 int64
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 uint32
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 uint64
sfixed32 4byte固定。 int32
sfixed64 8byte固定。 int64
bool 真偽値。 bool
string UTF-8またはASCIIの文字情報。 string
bytes 任意のバイトシーケンス。 []byte

Ruby

.proto Notes Ruby
double 8byte小数。 Float
float 4byte小数。 Float
int32 0以上の整数ならこっち。(符号付) Fixnum or Bignum (as required)
int64 0以上の整数ならこっち。(符号付) Bignum
uint32 0以上の整数ならこっち。(符号なし) Fixnum or Bignum (as required)
uint64 0以上の整数ならこっち。(符号なし) Bignum
sint32 負の値があるときはこっちが効率的。 Fixnum or Bignum (as required)
sint64 負の値があるときはこっちが効率的。 Bignum
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 Fixnum or Bignum (as required)
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 Bignum
sfixed32 4byte固定。 Fixnum or Bignum (as required)
sfixed64 8byte固定。 Bignum
bool 真偽値。 TrueClass/FalseClass
string UTF-8またはASCIIの文字情報。 String (UTF-8)
bytes 任意のバイトシーケンス。 String (ASCII-8BIT)

C#

.proto Notes C#
double 8byte小数。 double
float 4byte小数。 float
int32 0以上の整数ならこっち。(符号付) int
int64 0以上の整数ならこっち。(符号付) long
uint32 0以上の整数ならこっち。(符号なし) uint
uint64 0以上の整数ならこっち。(符号なし) ulong
sint32 負の値があるときはこっちが効率的。 int
sint64 負の値があるときはこっちが効率的。 long
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 uint
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 ulong
sfixed32 4byte固定。 int
sfixed64 8byte固定。 long
bool 真偽値。 bool
string UTF-8またはASCIIの文字情報。 string
bytes 任意のバイトシーケンス。 ByteString

PHP

.proto Notes PHP
double 8byte小数。 float
float 4byte小数。 float
int32 0以上の整数ならこっち。(符号付) integer
int64 0以上の整数ならこっち。(符号付) integer/string[5]
uint32 0以上の整数ならこっち。(符号なし) integer
uint64 0以上の整数ならこっち。(符号なし) integer/string[5]
sint32 負の値があるときはこっちが効率的。 integer
sint64 負の値があるときはこっちが効率的。 integer/string[5]
fixed32 4byte固定。 228を超える値の時unit32よりも効率的になることがある。 integer
fixed64 8byte固定。 256を超える値の時unit64よりも効率的になることがある。 integer/string[5]
sfixed32 4byte固定。 integer
sfixed64 8byte固定。 long
bool 真偽値。 boolean
string UTF-8またはASCIIの文字情報。 string
bytes 任意のバイトシーケンス。 string

[5] Integer is used on 64-bit machines and string is used on 32-bit machines.

39
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
39
24