本文整理汇总了Golang中github.com/google/flatbuffers/go.GetUOffsetT函数的典型用法代码示例。如果您正苦于以下问题:Golang GetUOffsetT函数的具体用法?Golang GetUOffsetT怎么用?Golang GetUOffsetT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetUOffsetT函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BenchmarkFlatBuffersUnmarshal
func BenchmarkFlatBuffersUnmarshal(b *testing.B) {
b.StopTimer()
builder := flatbuffers.NewBuilder(0)
data := generate()
ser := make([][]byte, len(data))
for i, d := range data {
ser[i] = serializeUsingFlatBuffers(builder, d)
}
b.ReportAllocs()
b.StartTimer()
for i := 0; i < b.N; i++ {
n := rand.Intn(len(ser))
o := FlatBufferA{}
sData := ser[n]
o.Init(sData, flatbuffers.GetUOffsetT(sData))
if validate != "" {
i := data[n]
spouseVal := o.Spouse() == byte(1)
correct := o.Name() == i.Name &&
o.Phone() == i.Phone &&
int(o.Siblings()) == i.Siblings &&
spouseVal == i.Spouse &&
o.Money() == i.Money &&
o.BirthDay() == i.BirthDay.Unix()
if !correct {
b.Fatalf("unmarshaled object differed:\n%v\n%v", i, o)
}
}
}
}
示例2: Unmarshal
func (s *FlatBufferSerializer) Unmarshal(d []byte, i interface{}) error {
a := i.(*A)
o := FlatBufferA{}
o.Init(d, flatbuffers.GetUOffsetT(d))
a.Name = string(o.Name())
a.BirthDay = time.Unix(o.BirthDay(), 0)
a.Phone = string(o.Phone())
a.Siblings = int(o.Siblings())
a.Spouse = o.Spouse() == byte(1)
a.Money = o.Money()
return nil
}
示例3: BenchmarkUnmarshal
func BenchmarkUnmarshal(b *testing.B) {
b.Run("colfer", func(b *testing.B) {
b.ReportAllocs()
for i := b.N; i > 0; i-- {
o := new(Colfer)
holdData = o
_, err := o.Unmarshal(colferSerials[i%len(colferSerials)])
if err != nil {
b.Fatal(err)
}
}
})
b.Run("protobuf", func(b *testing.B) {
b.ReportAllocs()
for i := b.N; i > 0; i-- {
o := new(ProtoBuf)
holdProtoBufData = o
err := o.Unmarshal(protoSerials[i%len(protoSerials)])
if err != nil {
b.Fatal(err)
}
}
})
b.Run("flatbuf", func(b *testing.B) {
b.ReportAllocs()
for i := b.N; i > 0; i-- {
o := new(Colfer)
holdData = o
bytes := flatSerials[i%len(flatSerials)]
buf := new(FlatBuffers)
buf.Init(bytes, flatbuffers.GetUOffsetT(bytes))
o.Key = buf.Key()
o.Host = string(buf.Host())
o.Port = buf.Port()
o.Size = buf.Size()
o.Hash = buf.Hash()
o.Ratio = buf.Ratio()
o.Route = buf.Route() == 1
}
})
}
示例4: GetRootAsMonster
func GetRootAsMonster(buf []byte, offset flatbuffers.UOffsetT) *Monster {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Monster{}
x.Init(buf, n+offset)
return x
}
示例5: GetRootAsFlatBufferColorGroup
func GetRootAsFlatBufferColorGroup(buf []byte, offset flatbuffers.UOffsetT) *FlatBufferColorGroup {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &FlatBufferColorGroup{}
x.Init(buf, n+offset)
return x
}
示例6: GetRootAsTestSimpleTableWithEnum
func GetRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &TestSimpleTableWithEnum{}
x.Init(buf, n+offset)
return x
}
示例7: GetRootAsRoute
func GetRootAsRoute(buf []byte, offset flatbuffers.UOffsetT) *Route {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Route{}
x.Init(buf, n+offset)
return x
}
示例8: GetRootAsPostingList
func GetRootAsPostingList(buf []byte, offset flatbuffers.UOffsetT) *PostingList {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &PostingList{}
x.Init(buf, n+offset)
return x
}
示例9: GetRootAsSecondTableInA
func GetRootAsSecondTableInA(buf []byte, offset flatbuffers.UOffsetT) *SecondTableInA {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &SecondTableInA{}
x.Init(buf, n+offset)
return x
}
示例10: GetRootAsNotice
func GetRootAsNotice(buf []byte, offset flatbuffers.UOffsetT) *Notice {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Notice{}
x.Init(buf, n+offset)
return x
}
示例11: GetRootAsTableInNestedNS
func GetRootAsTableInNestedNS(buf []byte, offset flatbuffers.UOffsetT) *TableInNestedNS {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &TableInNestedNS{}
x.Init(buf, n+offset)
return x
}
示例12: GetRootAsStatus
func GetRootAsStatus(buf []byte, offset flatbuffers.UOffsetT) *Status {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Status{}
x.Init(buf, n+offset)
return x
}
示例13: GetRootAsWeapon
func GetRootAsWeapon(buf []byte, offset flatbuffers.UOffsetT) *Weapon {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Weapon{}
x.Init(buf, n+offset)
return x
}
示例14: GetRootAsIndex
func GetRootAsIndex(buf []byte, offset flatbuffers.UOffsetT) *Index {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Index{}
x.Init(buf, n+offset)
return x
}