• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang bson.NextByte函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/youtube/vitess/go/bson.NextByte函数的典型用法代码示例。如果您正苦于以下问题:Golang NextByte函数的具体用法?Golang NextByte怎么用?Golang NextByte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NextByte函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: UnmarshalBson

// UnmarshalBson unmarshals QueryShard from buf.
func (qrs *QueryShard) UnmarshalBson(buf *bytes.Buffer) {
	bson.Next(buf, 4)

	kind := bson.NextByte(buf)
	for kind != bson.EOO {
		key := bson.ReadCString(buf)
		switch key {
		case "Sql":
			qrs.Sql = bson.DecodeString(buf, kind)
		case "BindVariables":
			qrs.BindVariables = tproto.DecodeBindVariablesBson(buf, kind)
		case "Keyspace":
			qrs.Keyspace = bson.DecodeString(buf, kind)
		case "TabletType":
			qrs.TabletType = topo.TabletType(bson.DecodeString(buf, kind))
		case "Shards":
			qrs.Shards = bson.DecodeStringArray(buf, kind)
		case "Session":
			qrs.Session = new(Session)
			qrs.Session.UnmarshalBson(buf)
		default:
			panic(bson.NewBsonError("Unrecognized tag %s", key))
		}
		kind = bson.NextByte(buf)
	}
}
开发者ID:rjammala,项目名称:vitess,代码行数:27,代码来源:vtgate_proto.go


示例2: UnmarshalBson

// UnmarshalBson bson-decodes into A.
func (a *A) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for A", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Name":
			a.Name = bson.DecodeString(buf, kind)
		case "BirthDay":
			a.BirthDay = bson.DecodeTime(buf, kind)
		case "Phone":
			a.Phone = bson.DecodeString(buf, kind)
		case "Siblings":
			a.Siblings = bson.DecodeInt(buf, kind)
		case "Spouse":
			a.Spouse = bson.DecodeBool(buf, kind)
		case "Money":
			a.Money = bson.DecodeFloat64(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:MarkBruns,项目名称:go_serialization_benchmarks,代码行数:31,代码来源:vitess_test.go


示例3: UnmarshalBson

// UnmarshalBson bson-decodes into SessionInfo.
func (sessionInfo *SessionInfo) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for SessionInfo", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "SessionId":
			sessionInfo.SessionId = bson.DecodeInt64(buf, kind)
		case "Err":
			// *mproto.RPCError
			if kind != bson.Null {
				sessionInfo.Err = new(mproto.RPCError)
				(*sessionInfo.Err).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:27,代码来源:session_info_bson.go


示例4: DecodeSrvShardArray

func DecodeSrvShardArray(buf *bytes.Buffer, kind byte) []SrvShard {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for SrvShard array", kind))
	}

	bson.Next(buf, 4)
	values := make([]SrvShard, 0, 8)
	kind = bson.NextByte(buf)
	for i := 0; kind != bson.EOO; i++ {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for SrvShard array", kind))
		}
		bson.ExpectIndex(buf, i)
		value := &SrvShard{}
		value.UnmarshalBson(buf)
		values = append(values, *value)
		kind = bson.NextByte(buf)
	}
	return values
}
开发者ID:rjammala,项目名称:vitess,代码行数:25,代码来源:srvshard.go


示例5: UnmarshalPKRowBson

func UnmarshalPKRowBson(buf *bytes.Buffer, kind byte) []interface{} {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for Query.Row", kind))
	}

	bson.Next(buf, 4)
	row := make([]interface{}, 0, 8)
	kind = bson.NextByte(buf)
	for i := 0; kind != bson.EOO; i++ {
		bson.ExpectIndex(buf, i)
		var val interface{}
		switch kind {
		case bson.Binary, bson.String:
			val = bson.DecodeString(buf, kind)
		case bson.Long:
			val = bson.DecodeInt64(buf, kind)
		case bson.Ulong:
			val = bson.DecodeUint64(buf, kind)
		}
		row = append(row, val)
		kind = bson.NextByte(buf)
	}
	return row
}
开发者ID:rjammala,项目名称:vitess,代码行数:29,代码来源:stream_event.go


示例6: UnmarshalBson

func (sqs *StreamQueryKeyRange) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	bson.VerifyObject(kind)
	bson.Next(buf, 4)

	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		keyName := bson.ReadCString(buf)
		switch keyName {
		case "Sql":
			sqs.Sql = bson.DecodeString(buf, kind)
		case "BindVariables":
			sqs.BindVariables = tproto.DecodeBindVariablesBson(buf, kind)
		case "Keyspace":
			sqs.Keyspace = bson.DecodeString(buf, kind)
		case "KeyRange":
			sqs.KeyRange = bson.DecodeString(buf, kind)
		case "TabletType":
			sqs.TabletType = topo.TabletType(bson.DecodeString(buf, kind))
		case "Session":
			if kind != bson.Null {
				sqs.Session = new(Session)
				sqs.Session.UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
		kind = bson.NextByte(buf)
	}
}
开发者ID:rudyLi,项目名称:vitess,代码行数:29,代码来源:vtgate_proto.go


示例7: UnmarshalBson

// UnmarshalBson bson-decodes into ShardSession.
func (shardSession *ShardSession) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for ShardSession", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Keyspace":
			shardSession.Keyspace = bson.DecodeString(buf, kind)
		case "Shard":
			shardSession.Shard = bson.DecodeString(buf, kind)
		case "TabletType":
			shardSession.TabletType.UnmarshalBson(buf, kind)
		case "TransactionId":
			shardSession.TransactionId = bson.DecodeInt64(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:richarwu,项目名称:vitess,代码行数:27,代码来源:shard_session_bson.go


示例8: UnmarshalBson

func (zkNode *ZkNode) UnmarshalBson(buf *bytes.Buffer) {
	bson.Next(buf, 4)

	kind := bson.NextByte(buf)
	for kind != bson.EOO {
		key := bson.ReadCString(buf)
		switch key {
		case "Path":
			zkNode.Path = bson.DecodeString(buf, kind)
		case "Data":
			zkNode.Data = bson.DecodeString(buf, kind)
		case "Stat":
			if kind != bson.Object {
				panic(bson.NewBsonError("Unexpected data type %v for Stat", kind))
			}
			zkNode.Stat.UnmarshalBson(buf)
		case "Children":
			zkNode.Children = bson.DecodeStringArray(buf, kind)
		case "Cached":
			zkNode.Cached = bson.DecodeBool(buf, kind)
		case "Stale":
			zkNode.Stale = bson.DecodeBool(buf, kind)
		default:
			panic(bson.NewBsonError("Unrecognized tag %s for ZkNode", key))
		}
		kind = bson.NextByte(buf)
	}
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:28,代码来源:zkocc_bson.go


示例9: unmarshalZkNodeArray

func unmarshalZkNodeArray(buf *bytes.Buffer, name string, kind byte) []*ZkNode {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for %v", kind, name))
	}

	bson.Next(buf, 4)
	values := make([]*ZkNode, 0, 8)
	kind = bson.NextByte(buf)
	for i := 0; kind != bson.EOO; i++ {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for %v", kind, name))
		}
		bson.ExpectIndex(buf, i)
		zkNode := &ZkNode{}
		zkNode.UnmarshalBson(buf)
		values = append(values, zkNode)
		kind = bson.NextByte(buf)
	}
	return values
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:25,代码来源:zkocc_bson.go


示例10: UnmarshalBson

func (sk *SrvKeyspace) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	bson.VerifyObject(kind)
	bson.Next(buf, 4)

	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		keyName := bson.ReadCString(buf)
		switch keyName {
		case "Partitions":
			sk.Partitions = DecodeKeyspacePartitionMap(buf, kind)
		case "Shards":
			sk.Shards = DecodeSrvShardArray(buf, kind)
		case "TabletTypes":
			sk.TabletTypes = DecodeTabletTypeArray(buf, kind)
		case "ShardingColumnName":
			sk.ShardingColumnName = bson.DecodeString(buf, kind)
		case "ShardingColumnType":
			sk.ShardingColumnType = key.KeyspaceIdType(bson.DecodeString(buf, kind))
		case "ServedFrom":
			sk.ServedFrom = DecodeServedFrom(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
		kind = bson.NextByte(buf)
	}
}
开发者ID:rudyLi,项目名称:vitess,代码行数:26,代码来源:srvshard.go


示例11: UnmarshalBson

// UnmarshalBson bson-decodes into MyType.
func (myType *MyType) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for MyType", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Cust1":
			myType.Cust1.UnmarshalBson(buf, kind)
		case "Cust2":
			// *Custom1
			if kind != bson.Null {
				myType.Cust2 = new(Custom1)
				(*myType.Cust2).UnmarshalBson(buf, kind)
			}
		case "Cust3":
			myType.Cust3.UnmarshalBson(buf, kind)
		case "Cust4":
			// *pkg.Custom2
			if kind != bson.Null {
				myType.Cust4 = new(pkg.Custom2)
				(*myType.Cust4).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:hfeeki,项目名称:vitess,代码行数:35,代码来源:output_custom.go


示例12: UnmarshalBson

// UnmarshalBson bson-decodes into KeyspacePartition.
func (keyspacePartition *KeyspacePartition) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for KeyspacePartition", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "ShardReferences":
			// []ShardReference
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for keyspacePartition.ShardReferences", kind))
				}
				bson.Next(buf, 4)
				keyspacePartition.ShardReferences = make([]ShardReference, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 ShardReference
					_v1.UnmarshalBson(buf, kind)
					keyspacePartition.ShardReferences = append(keyspacePartition.ShardReferences, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:kuipertan,项目名称:vitess,代码行数:34,代码来源:keyspace_partition_bson.go


示例13: UnmarshalBson

// UnmarshalBson bson-decodes into QueryResultList.
func (queryResultList *QueryResultList) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for QueryResultList", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "List":
			// []mproto.QueryResult
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for queryResultList.List", kind))
				}
				bson.Next(buf, 4)
				queryResultList.List = make([]mproto.QueryResult, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 mproto.QueryResult
					_v1.UnmarshalBson(buf, kind)
					queryResultList.List = append(queryResultList.List, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:34,代码来源:query_result_list_bson.go


示例14: UnmarshalBson

// UnmarshalBson bson-decodes into BlpPositionList.
func (blpPositionList *BlpPositionList) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for BlpPositionList", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Entries":
			// []BlpPosition
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for blpPositionList.Entries", kind))
				}
				bson.Next(buf, 4)
				blpPositionList.Entries = make([]BlpPosition, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 BlpPosition
					_v1.UnmarshalBson(buf, kind)
					blpPositionList.Entries = append(blpPositionList.Entries, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:34,代码来源:blp_position_list_bson.go


示例15: decodeShardSessionsBson

func decodeShardSessionsBson(buf *bytes.Buffer, kind byte) []*ShardSession {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for ShardSessions", kind))
	}

	bson.Next(buf, 4)
	shardSessions := make([]*ShardSession, 0, 8)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for ShardSession", kind))
		}
		bson.SkipIndex(buf)
		shardSession := new(ShardSession)
		shardSession.UnmarshalBson(buf, kind)
		shardSessions = append(shardSessions, shardSession)
		kind = bson.NextByte(buf)
	}
	return shardSessions
}
开发者ID:rudyLi,项目名称:vitess,代码行数:25,代码来源:vtgate_proto.go


示例16: UnmarshalBson

// UnmarshalBson bson-decodes into BoundQuery.
func (boundQuery *BoundQuery) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for BoundQuery", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Sql":
			boundQuery.Sql = bson.DecodeString(buf, kind)
		case "BindVariables":
			// map[string]interface{}
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for boundQuery.BindVariables", kind))
				}
				bson.Next(buf, 4)
				boundQuery.BindVariables = make(map[string]interface{})
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v1 interface{}
					_v1 = bson.DecodeInterface(buf, kind)
					boundQuery.BindVariables[_k] = _v1
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:36,代码来源:bound_query_bson.go


示例17: UnmarshalBson

// UnmarshalBson bson-decodes into Statement.
func (statement *Statement) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for Statement", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Category":
			statement.Category = bson.DecodeInt(buf, kind)
		case "Charset":
			// *mproto.Charset
			if kind != bson.Null {
				statement.Charset = new(mproto.Charset)
				(*statement.Charset).UnmarshalBson(buf, kind)
			}
		case "Sql":
			statement.Sql = bson.DecodeBinary(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:29,代码来源:statement_bson.go


示例18: UnmarshalBson

func (sk *SrvKeyspace) UnmarshalBson(buf *bytes.Buffer) {
	bson.Next(buf, 4)

	kind := bson.NextByte(buf)
	for kind != bson.EOO {
		keyName := bson.ReadCString(buf)
		switch keyName {
		case "Partitions":
			sk.Partitions = DecodeKeyspacePartitionMap(buf, kind)
		case "Shards":
			sk.Shards = DecodeSrvShardArray(buf, kind)
		case "TabletTypes":
			sk.TabletTypes = DecodeTabletTypeArray(buf, kind)
		case "ShardingColumnName":
			sk.ShardingColumnName = bson.DecodeString(buf, kind)
		case "ShardingColumnType":
			sk.ShardingColumnType = key.KeyspaceIdType(bson.DecodeString(buf, kind))
		case "ServedFrom":
			sk.ServedFrom = DecodeServedFrom(buf, kind)
		default:
			panic(bson.NewBsonError("Unrecognized tag %s", keyName))
		}
		kind = bson.NextByte(buf)
	}
}
开发者ID:qinbo,项目名称:vitess,代码行数:25,代码来源:srvshard.go


示例19: DecodeKeyspacePartitionMap

func DecodeKeyspacePartitionMap(buf *bytes.Buffer, kind byte) map[TabletType]*KeyspacePartition {
	switch kind {
	case bson.Object:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for KeyspacePartition map", kind))
	}

	bson.Next(buf, 4)
	values := make(map[TabletType]*KeyspacePartition)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for KeyspacePartition map", kind))
		}
		key := bson.ReadCString(buf)
		value := &KeyspacePartition{}
		value.UnmarshalBson(buf)
		values[TabletType(key)] = value
		kind = bson.NextByte(buf)
	}
	return values
}
开发者ID:rjammala,项目名称:vitess,代码行数:25,代码来源:srvshard.go


示例20: UnmarshalBson

// UnmarshalBson bson-decodes into GTIDField.
func (gf *GTIDField) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	switch kind {
	case bson.EOO, bson.Object:
		// valid
	case bson.Null:
		return
	default:
		panic(bson.NewBsonError("unexpected kind %v for GTIDField", kind))
	}
	bson.Next(buf, 4)

	// We expect exactly zero or one fields in this bson object.
	kind = bson.NextByte(buf)
	if kind == bson.EOO {
		// The GTID was nil, nothing to do.
		return
	}

	// The field name is the MySQL flavor.
	flavor := bson.ReadCString(buf)
	value := bson.DecodeString(buf, kind)

	// Check for and consume the end byte.
	if kind = bson.NextByte(buf); kind != bson.EOO {
		panic(bson.NewBsonError("too many fields for GTIDField"))
	}

	// Parse the value.
	gtid, err := ParseGTID(flavor, value)
	if err != nil {
		panic(bson.NewBsonError("invalid value %v for GTIDField: %v", value, err))
	}
	gf.Value = gtid
}
开发者ID:chinna1986,项目名称:vitess,代码行数:35,代码来源:gtid.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang bson.ReadCString函数代码示例发布时间:2022-05-28
下一篇:
Golang bson.Next函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap