// UnmarshalBson bson-decodes into BatchQueryShard.
func (batchQueryShard *BatchQueryShard) 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 BatchQueryShard", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Queries":
			// []tproto.BoundQuery
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for batchQueryShard.Queries", kind))
				}
				bson.Next(buf, 4)
				batchQueryShard.Queries = make([]tproto.BoundQuery, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 tproto.BoundQuery
					_v1.UnmarshalBson(buf, kind)
					batchQueryShard.Queries = append(batchQueryShard.Queries, _v1)
				}
			}
		case "Keyspace":
			batchQueryShard.Keyspace = bson.DecodeString(buf, kind)
		case "Shards":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for batchQueryShard.Shards", kind))
				}
				bson.Next(buf, 4)
				batchQueryShard.Shards = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 string
					_v2 = bson.DecodeString(buf, kind)
					batchQueryShard.Shards = append(batchQueryShard.Shards, _v2)
				}
			}
		case "TabletType":
			batchQueryShard.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				batchQueryShard.Session = new(Session)
				(*batchQueryShard.Session).UnmarshalBson(buf, kind)
			}
		case "NotInTransaction":
			batchQueryShard.NotInTransaction = bson.DecodeBool(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
// UnmarshalBson bson-decodes into KeyspaceIdBatchQuery.
func (keyspaceIdBatchQuery *KeyspaceIdBatchQuery) 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 KeyspaceIdBatchQuery", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Queries":
			// []tproto.BoundQuery
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for keyspaceIdBatchQuery.Queries", kind))
				}
				bson.Next(buf, 4)
				keyspaceIdBatchQuery.Queries = make([]tproto.BoundQuery, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 tproto.BoundQuery
					_v1.UnmarshalBson(buf, kind)
					keyspaceIdBatchQuery.Queries = append(keyspaceIdBatchQuery.Queries, _v1)
				}
			}
		case "Keyspace":
			keyspaceIdBatchQuery.Keyspace = bson.DecodeString(buf, kind)
		case "KeyspaceIds":
			// []kproto.KeyspaceId
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for keyspaceIdBatchQuery.KeyspaceIds", kind))
				}
				bson.Next(buf, 4)
				keyspaceIdBatchQuery.KeyspaceIds = make([]kproto.KeyspaceId, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 kproto.KeyspaceId
					_v2.UnmarshalBson(buf, kind)
					keyspaceIdBatchQuery.KeyspaceIds = append(keyspaceIdBatchQuery.KeyspaceIds, _v2)
				}
			}
		case "TabletType":
			keyspaceIdBatchQuery.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				keyspaceIdBatchQuery.Session = new(Session)
				(*keyspaceIdBatchQuery.Session).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#3
0
// UnmarshalBson bson-decodes into SrvShard.
func (srvShard *SrvShard) 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 SrvShard", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Name":
			srvShard.Name = bson.DecodeString(buf, kind)
		case "KeyRange":
			srvShard.KeyRange.UnmarshalBson(buf, kind)
		case "ServedTypes":
			// []TabletType
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for srvShard.ServedTypes", kind))
				}
				bson.Next(buf, 4)
				srvShard.ServedTypes = make([]TabletType, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 TabletType
					_v1.UnmarshalBson(buf, kind)
					srvShard.ServedTypes = append(srvShard.ServedTypes, _v1)
				}
			}
		case "MasterCell":
			srvShard.MasterCell = bson.DecodeString(buf, kind)
		case "TabletTypes":
			// []TabletType
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for srvShard.TabletTypes", kind))
				}
				bson.Next(buf, 4)
				srvShard.TabletTypes = make([]TabletType, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 TabletType
					_v2.UnmarshalBson(buf, kind)
					srvShard.TabletTypes = append(srvShard.TabletTypes, _v2)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
// UnmarshalBson bson-decodes into BinlogTransaction.
func (binlogTransaction *BinlogTransaction) 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 BinlogTransaction", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Statements":
			// []Statement
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for binlogTransaction.Statements", kind))
				}
				bson.Next(buf, 4)
				binlogTransaction.Statements = make([]Statement, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 Statement
					_v1.UnmarshalBson(buf, kind)
					binlogTransaction.Statements = append(binlogTransaction.Statements, _v1)
				}
			}
		case "GroupId":
			binlogTransaction.GroupId = bson.DecodeInt64(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#5
0
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 kind != bson.EOO {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for %v", kind, name))
		}
		bson.SkipIndex(buf)
		zkNode := &ZkNode{}
		zkNode.UnmarshalBson(buf, kind)
		values = append(values, zkNode)
		kind = bson.NextByte(buf)
	}
	return values
}
示例#6
0
// UnmarshalBson bson-decodes into ZkPathV.
func (zkPathV *ZkPathV) 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 ZkPathV", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Paths":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for zkPathV.Paths", kind))
				}
				bson.Next(buf, 4)
				zkPathV.Paths = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 string
					_v1 = bson.DecodeString(buf, kind)
					zkPathV.Paths = append(zkPathV.Paths, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
// 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)
		}
	}
}
// 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)
		}
	}
}
// UnmarshalBson bson-decodes into KeyspaceIdQuery.
func (keyspaceIdQuery *KeyspaceIdQuery) 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 KeyspaceIdQuery", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Sql":
			keyspaceIdQuery.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 keyspaceIdQuery.BindVariables", kind))
				}
				bson.Next(buf, 4)
				keyspaceIdQuery.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)
					keyspaceIdQuery.BindVariables[_k] = _v1
				}
			}
		case "Keyspace":
			keyspaceIdQuery.Keyspace = bson.DecodeString(buf, kind)
		case "KeyspaceIds":
			// []kproto.KeyspaceId
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for keyspaceIdQuery.KeyspaceIds", kind))
				}
				bson.Next(buf, 4)
				keyspaceIdQuery.KeyspaceIds = make([]kproto.KeyspaceId, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 kproto.KeyspaceId
					_v2.UnmarshalBson(buf, kind)
					keyspaceIdQuery.KeyspaceIds = append(keyspaceIdQuery.KeyspaceIds, _v2)
				}
			}
		case "TabletType":
			keyspaceIdQuery.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				keyspaceIdQuery.Session = new(Session)
				(*keyspaceIdQuery.Session).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#10
0
func UnmarshalStatementsBson(buf *bytes.Buffer, kind byte) []Statement {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for BinlogTransaction.Statements", kind))
	}

	bson.Next(buf, 4)
	statements := make([]Statement, 0, 8)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for Query.Field", kind))
		}
		bson.SkipIndex(buf)
		var statement Statement
		statement.UnmarshalBson(buf, kind)
		statements = append(statements, statement)
		kind = bson.NextByte(buf)
	}
	return statements
}
示例#11
0
文件: srvshard.go 项目: rudyLi/vitess
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 kind != bson.EOO {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for SrvShard array", kind))
		}
		bson.SkipIndex(buf)
		value := &SrvShard{}
		value.UnmarshalBson(buf, kind)
		values = append(values, *value)
		kind = bson.NextByte(buf)
	}
	return values
}
示例#12
0
文件: bson.go 项目: rudyLi/vitess
func DecodeFieldsBson(buf *bytes.Buffer, kind byte) []Field {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for Query.Fields", kind))
	}

	bson.Next(buf, 4)
	fields := make([]Field, 0, 8)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		if kind != bson.Object {
			panic(bson.NewBsonError("Unexpected data type %v for Query.Field", kind))
		}
		bson.SkipIndex(buf)
		var field Field
		UnmarshalFieldBson(&field, buf)
		fields = append(fields, field)
		kind = bson.NextByte(buf)
	}
	return fields
}
示例#13
0
// 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)
		}
	}
}
示例#14
0
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
}
示例#15
0
// UnmarshalBson bson-decodes into SrvKeyspaceNames.
func (srvKeyspaceNames *SrvKeyspaceNames) 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 SrvKeyspaceNames", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Entries":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for srvKeyspaceNames.Entries", kind))
				}
				bson.Next(buf, 4)
				srvKeyspaceNames.Entries = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 string
					_v1 = bson.DecodeString(buf, kind)
					srvKeyspaceNames.Entries = append(srvKeyspaceNames.Entries, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#16
0
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 kind != bson.EOO {
		bson.SkipIndex(buf)
		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
}
示例#17
0
// UnmarshalBson bson-decodes into BoundShardQuery.
func (boundShardQuery *BoundShardQuery) 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 BoundShardQuery", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Sql":
			boundShardQuery.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 boundShardQuery.BindVariables", kind))
				}
				bson.Next(buf, 4)
				boundShardQuery.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)
					boundShardQuery.BindVariables[_k] = _v1
				}
			}
		case "Keyspace":
			boundShardQuery.Keyspace = bson.DecodeString(buf, kind)
		case "Shards":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for boundShardQuery.Shards", kind))
				}
				bson.Next(buf, 4)
				boundShardQuery.Shards = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 string
					_v2 = bson.DecodeString(buf, kind)
					boundShardQuery.Shards = append(boundShardQuery.Shards, _v2)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#18
0
// UnmarshalBson bson-decodes into ZkNode.
func (zkNode *ZkNode) 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 ZkNode", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Path":
			zkNode.Path = bson.DecodeString(buf, kind)
		case "Data":
			zkNode.Data = bson.DecodeString(buf, kind)
		case "Stat":
			zkNode.Stat.UnmarshalBson(buf, kind)
		case "Children":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for zkNode.Children", kind))
				}
				bson.Next(buf, 4)
				zkNode.Children = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 string
					_v1 = bson.DecodeString(buf, kind)
					zkNode.Children = append(zkNode.Children, _v1)
				}
			}
		case "Cached":
			zkNode.Cached = bson.DecodeBool(buf, kind)
		case "Stale":
			zkNode.Stale = bson.DecodeBool(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#19
0
文件: bson.go 项目: rudyLi/vitess
func DecodeRowsBson(buf *bytes.Buffer, kind byte) [][]sqltypes.Value {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for Query.Rows", kind))
	}

	bson.Next(buf, 4)
	rows := make([][]sqltypes.Value, 0, 8)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		bson.SkipIndex(buf)
		rows = append(rows, DecodeRowBson(buf, kind))
		kind = bson.NextByte(buf)
	}
	return rows
}
示例#20
0
// UnmarshalBson bson-decodes into BatchQueryShard.
func (batchQueryShard *BatchQueryShard) 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 BatchQueryShard", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Queries":
			// []BoundShardQuery
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for batchQueryShard.Queries", kind))
				}
				bson.Next(buf, 4)
				batchQueryShard.Queries = make([]BoundShardQuery, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 BoundShardQuery
					_v1.UnmarshalBson(buf, kind)
					batchQueryShard.Queries = append(batchQueryShard.Queries, _v1)
				}
			}
		case "TabletType":
			batchQueryShard.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				batchQueryShard.Session = new(Session)
				(*batchQueryShard.Session).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#21
0
// UnmarshalBson bson-decodes into QueryList.
func (queryList *QueryList) 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 QueryList", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Queries":
			// []BoundQuery
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for queryList.Queries", kind))
				}
				bson.Next(buf, 4)
				queryList.Queries = make([]BoundQuery, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 BoundQuery
					_v1.UnmarshalBson(buf, kind)
					queryList.Queries = append(queryList.Queries, _v1)
				}
			}
		case "SessionId":
			queryList.SessionId = bson.DecodeInt64(buf, kind)
		case "AsTransaction":
			queryList.AsTransaction = bson.DecodeBool(buf, kind)
		case "TransactionId":
			queryList.TransactionId = bson.DecodeInt64(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#22
0
// UnmarshalBson bson-decodes into Session.
func (session *Session) 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 Session", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "InTransaction":
			session.InTransaction = bson.DecodeBool(buf, kind)
		case "ShardSessions":
			// []*ShardSession
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for session.ShardSessions", kind))
				}
				bson.Next(buf, 4)
				session.ShardSessions = make([]*ShardSession, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 *ShardSession
					// *ShardSession
					if kind != bson.Null {
						_v1 = new(ShardSession)
						(*_v1).UnmarshalBson(buf, kind)
					}
					session.ShardSessions = append(session.ShardSessions, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#23
0
文件: bson.go 项目: rudyLi/vitess
func DecodeResultsBson(buf *bytes.Buffer, kind byte) (results []mproto.QueryResult) {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for Queries", kind))
	}

	bson.Next(buf, 4)
	results = make([]mproto.QueryResult, 0, 8)
	kind = bson.NextByte(buf)
	var result mproto.QueryResult
	for kind != bson.EOO {
		bson.SkipIndex(buf)
		result.UnmarshalBson(buf, kind)
		results = append(results, result)
		kind = bson.NextByte(buf)
	}
	return results
}
示例#24
0
文件: bson.go 项目: rudyLi/vitess
func DecodeQueriesBson(buf *bytes.Buffer, kind byte) (queries []BoundQuery) {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for Queries", kind))
	}

	bson.Next(buf, 4)
	queries = make([]BoundQuery, 0, 8)
	kind = bson.NextByte(buf)
	var bdq BoundQuery
	for kind != bson.EOO {
		bson.SkipIndex(buf)
		bdq.UnmarshalBson(buf, kind)
		queries = append(queries, bdq)
		kind = bson.NextByte(buf)
	}
	return queries
}
示例#25
0
文件: srvshard.go 项目: rudyLi/vitess
func DecodeTabletTypeArray(buf *bytes.Buffer, kind byte) []TabletType {
	switch kind {
	case bson.Array:
		// valid
	case bson.Null:
		return nil
	default:
		panic(bson.NewBsonError("Unexpected data type %v for TabletType array", kind))
	}

	bson.Next(buf, 4)
	values := make([]TabletType, 0, 8)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		if kind != bson.Binary {
			panic(bson.NewBsonError("Unexpected data type %v for TabletType array", kind))
		}
		bson.SkipIndex(buf)
		values = append(values, TabletType(bson.DecodeString(buf, kind)))
		kind = bson.NextByte(buf)
	}
	return values
}
示例#26
0
// UnmarshalBson bson-decodes into ZkNodeV.
func (zkNodeV *ZkNodeV) 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 ZkNodeV", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Nodes":
			// []*ZkNode
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for zkNodeV.Nodes", kind))
				}
				bson.Next(buf, 4)
				zkNodeV.Nodes = make([]*ZkNode, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 *ZkNode
					// *ZkNode
					if kind != bson.Null {
						_v1 = new(ZkNode)
						(*_v1).UnmarshalBson(buf, kind)
					}
					zkNodeV.Nodes = append(zkNodeV.Nodes, _v1)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#27
0
文件: bson.go 项目: rudyLi/vitess
func DecodeRowBson(buf *bytes.Buffer, kind byte) []sqltypes.Value {
	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([]sqltypes.Value, 0, 8)
	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		bson.SkipIndex(buf)
		if kind != bson.Null {
			row = append(row, sqltypes.MakeString(bson.DecodeBinary(buf, kind)))
		} else {
			row = append(row, sqltypes.Value{})
		}
		kind = bson.NextByte(buf)
	}
	return row
}
示例#28
0
// UnmarshalBson bson-decodes into StreamEvent.
func (streamEvent *StreamEvent) 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 StreamEvent", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Category":
			streamEvent.Category = bson.DecodeString(buf, kind)
		case "TableName":
			streamEvent.TableName = bson.DecodeString(buf, kind)
		case "PKColNames":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for streamEvent.PKColNames", kind))
				}
				bson.Next(buf, 4)
				streamEvent.PKColNames = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 string
					_v1 = bson.DecodeString(buf, kind)
					streamEvent.PKColNames = append(streamEvent.PKColNames, _v1)
				}
			}
		case "PKValues":
			// [][]interface{}
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for streamEvent.PKValues", kind))
				}
				bson.Next(buf, 4)
				streamEvent.PKValues = make([][]interface{}, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 []interface{}
					// []interface{}
					if kind != bson.Null {
						if kind != bson.Array {
							panic(bson.NewBsonError("unexpected kind %v for _v2", kind))
						}
						bson.Next(buf, 4)
						_v2 = make([]interface{}, 0, 8)
						for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
							bson.SkipIndex(buf)
							var _v3 interface{}
							_v3 = bson.DecodeInterface(buf, kind)
							_v2 = append(_v2, _v3)
						}
					}
					streamEvent.PKValues = append(streamEvent.PKValues, _v2)
				}
			}
		case "Sql":
			streamEvent.Sql = bson.DecodeString(buf, kind)
		case "Timestamp":
			streamEvent.Timestamp = bson.DecodeInt64(buf, kind)
		case "GTIDField":
			streamEvent.GTIDField.UnmarshalBson(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#29
0
// 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 "Slice":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for myType.Slice", kind))
				}
				bson.Next(buf, 4)
				myType.Slice = make([]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 string
					_v1 = bson.DecodeString(buf, kind)
					myType.Slice = append(myType.Slice, _v1)
				}
			}
		case "SliceBytes":
			// [][]byte
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for myType.SliceBytes", kind))
				}
				bson.Next(buf, 4)
				myType.SliceBytes = make([][]byte, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 []byte
					_v2 = bson.DecodeBinary(buf, kind)
					myType.SliceBytes = append(myType.SliceBytes, _v2)
				}
			}
		case "SlicePtr":
			// []*string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for myType.SlicePtr", kind))
				}
				bson.Next(buf, 4)
				myType.SlicePtr = make([]*string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v3 *string
					// *string
					if kind != bson.Null {
						_v3 = new(string)
						(*_v3) = bson.DecodeString(buf, kind)
					}
					myType.SlicePtr = append(myType.SlicePtr, _v3)
				}
			}
		case "SliceSlice":
			// [][]string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for myType.SliceSlice", kind))
				}
				bson.Next(buf, 4)
				myType.SliceSlice = make([][]string, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v4 []string
					// []string
					if kind != bson.Null {
						if kind != bson.Array {
							panic(bson.NewBsonError("unexpected kind %v for _v4", kind))
						}
						bson.Next(buf, 4)
						_v4 = make([]string, 0, 8)
						for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
							bson.SkipIndex(buf)
							var _v5 string
							_v5 = bson.DecodeString(buf, kind)
							_v4 = append(_v4, _v5)
						}
					}
					myType.SliceSlice = append(myType.SliceSlice, _v4)
				}
			}
		case "SliceMap":
			// []map[string]int64
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for myType.SliceMap", kind))
				}
				bson.Next(buf, 4)
				myType.SliceMap = make([]map[string]int64, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v6 map[string]int64
					// map[string]int64
					if kind != bson.Null {
						if kind != bson.Object {
							panic(bson.NewBsonError("unexpected kind %v for _v6", kind))
						}
						bson.Next(buf, 4)
						_v6 = make(map[string]int64)
						for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
							_k := bson.ReadCString(buf)
							var _v7 int64
							_v7 = bson.DecodeInt64(buf, kind)
							_v6[_k] = _v7
						}
					}
					myType.SliceMap = append(myType.SliceMap, _v6)
				}
			}
		case "SliceCustom":
			// []Custom
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for myType.SliceCustom", kind))
				}
				bson.Next(buf, 4)
				myType.SliceCustom = make([]Custom, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v8 Custom
					_v8.UnmarshalBson(buf, kind)
					myType.SliceCustom = append(myType.SliceCustom, _v8)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
示例#30
0
// UnmarshalBson bson-decodes into Result.
func (result *Result) 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 Result", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Fields":
			// []*query.Field
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for result.Fields", kind))
				}
				bson.Next(buf, 4)
				result.Fields = make([]*querypb.Field, 0, 8)
				var f BSONField
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v1 *querypb.Field
					// *query.Field
					_v1 = new(querypb.Field)
					bson.UnmarshalFromBuffer(buf, &f)
					_v1.Name = f.Name
					_v1.Type = MySQLToType(f.Type, f.Flags)
					result.Fields = append(result.Fields, _v1)
				}
			}
		case "RowsAffected":
			result.RowsAffected = bson.DecodeUint64(buf, kind)
		case "InsertId":
			result.InsertID = bson.DecodeUint64(buf, kind)
		case "Rows":
			// [][]Value
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for result.Rows", kind))
				}
				bson.Next(buf, 4)
				result.Rows = make([][]Value, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 []Value
					// []Value
					if kind != bson.Null {
						if kind != bson.Array {
							panic(bson.NewBsonError("unexpected kind %v for _v2", kind))
						}
						bson.Next(buf, 4)
						_v2 = make([]Value, 0, 8)
						for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
							bson.SkipIndex(buf)
							var _v3 Value
							_v3.UnmarshalBson(buf, kind)
							_v2 = append(_v2, _v3)
						}
					}
					result.Rows = append(result.Rows, _v2)
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}