当前位置: 首页>>代码示例>>Golang>>正文


Golang go.GetUOffsetT函数代码示例

本文整理汇总了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)
			}
		}
	}
}
开发者ID:junchaowu,项目名称:go_serialization_benchmarks,代码行数:32,代码来源:serialization_benchmarks_test.go

示例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
}
开发者ID:FiloSottile,项目名称:go_serialization_benchmarks,代码行数:12,代码来源:serialization_benchmarks_test.go

示例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
		}
	})
}
开发者ID:pascaldekloe,项目名称:colfer,代码行数:46,代码来源:bench_test.go

示例4: GetRootAsMonster

func GetRootAsMonster(buf []byte, offset flatbuffers.UOffsetT) *Monster {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Monster{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:BlueBrain,项目名称:flatbuffers,代码行数:6,代码来源:Monster.go

示例5: GetRootAsFlatBufferColorGroup

func GetRootAsFlatBufferColorGroup(buf []byte, offset flatbuffers.UOffsetT) *FlatBufferColorGroup {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &FlatBufferColorGroup{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:jameswei,项目名称:gosercomp,代码行数:6,代码来源:FlatBufferColorGroup.go

示例6: GetRootAsTestSimpleTableWithEnum

func GetRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &TestSimpleTableWithEnum{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:google,项目名称:flatbuffers,代码行数:6,代码来源:TestSimpleTableWithEnum.go

示例7: GetRootAsRoute

func GetRootAsRoute(buf []byte, offset flatbuffers.UOffsetT) *Route {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Route{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:jeffallen,项目名称:routedb,代码行数:6,代码来源:Route.go

示例8: GetRootAsPostingList

func GetRootAsPostingList(buf []byte, offset flatbuffers.UOffsetT) *PostingList {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &PostingList{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:cayleydb,项目名称:dgraph,代码行数:6,代码来源:PostingList.go

示例9: GetRootAsSecondTableInA

func GetRootAsSecondTableInA(buf []byte, offset flatbuffers.UOffsetT) *SecondTableInA {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &SecondTableInA{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:google,项目名称:flatbuffers,代码行数:6,代码来源:SecondTableInA.go

示例10: GetRootAsNotice

func GetRootAsNotice(buf []byte, offset flatbuffers.UOffsetT) *Notice {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Notice{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:pengqiuyuan,项目名称:gomiddle,代码行数:6,代码来源:Notice.go

示例11: GetRootAsTableInNestedNS

func GetRootAsTableInNestedNS(buf []byte, offset flatbuffers.UOffsetT) *TableInNestedNS {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &TableInNestedNS{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:google,项目名称:flatbuffers,代码行数:6,代码来源:TableInNestedNS.go

示例12: GetRootAsStatus

func GetRootAsStatus(buf []byte, offset flatbuffers.UOffsetT) *Status {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Status{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:pengqiuyuan,项目名称:gomiddle,代码行数:6,代码来源:Status.go

示例13: GetRootAsWeapon

func GetRootAsWeapon(buf []byte, offset flatbuffers.UOffsetT) *Weapon {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Weapon{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:leo-lu,项目名称:GO,代码行数:6,代码来源:Weapon.go

示例14: GetRootAsIndex

func GetRootAsIndex(buf []byte, offset flatbuffers.UOffsetT) *Index {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Index{}
	x.Init(buf, n+offset)
	return x
}
开发者ID:jackdoe,项目名称:no,代码行数:6,代码来源:Index.go


注:本文中的github.com/google/flatbuffers/go.GetUOffsetT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。