Ejemplo n.º 1
0
// 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)
		}
	}
}
Ejemplo n.º 2
0
// 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)
		}
	}
}
Ejemplo n.º 3
0
// UnmarshalBson bson-decodes into SrvKeyspace.
func (srvKeyspace *SrvKeyspace) 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 SrvKeyspace", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Partitions":
			// map[TabletType]*KeyspacePartition
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for srvKeyspace.Partitions", kind))
				}
				bson.Next(buf, 4)
				srvKeyspace.Partitions = make(map[TabletType]*KeyspacePartition)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := TabletType(bson.ReadCString(buf))
					var _v1 *KeyspacePartition
					// *KeyspacePartition
					if kind != bson.Null {
						_v1 = new(KeyspacePartition)
						(*_v1).UnmarshalBson(buf, kind)
					}
					srvKeyspace.Partitions[_k] = _v1
				}
			}
		case "ShardingColumnName":
			srvKeyspace.ShardingColumnName = bson.DecodeString(buf, kind)
		case "ShardingColumnType":
			srvKeyspace.ShardingColumnType.UnmarshalBson(buf, kind)
		case "ServedFrom":
			// map[TabletType]string
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for srvKeyspace.ServedFrom", kind))
				}
				bson.Next(buf, 4)
				srvKeyspace.ServedFrom = make(map[TabletType]string)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := TabletType(bson.ReadCString(buf))
					var _v2 string
					_v2 = bson.DecodeString(buf, kind)
					srvKeyspace.ServedFrom[_k] = _v2
				}
			}
		case "SplitShardCount":
			srvKeyspace.SplitShardCount = bson.DecodeInt32(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
Ejemplo n.º 4
0
// UnmarshalBson bson-decodes into Query.
func (query *Query) 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 Query", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "CallerID":
			// *tproto.CallerID
			if kind != bson.Null {
				query.CallerID = new(tproto.CallerID)
				(*query.CallerID).UnmarshalBson(buf, kind)
			}
		case "Sql":
			query.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 query.BindVariables", kind))
				}
				bson.Next(buf, 4)
				query.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)
					query.BindVariables[_k] = _v1
				}
			}
		case "TabletType":
			query.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				query.Session = new(Session)
				(*query.Session).UnmarshalBson(buf, kind)
			}
		case "NotInTransaction":
			query.NotInTransaction = bson.DecodeBool(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
Ejemplo n.º 5
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)
		}
	}
}
Ejemplo n.º 6
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":
			// []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)
		}
	}
}
Ejemplo n.º 7
0
// 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)
		}
	}
}
Ejemplo n.º 8
0
// UnmarshalBson bson-decodes into QueryResult.
func (queryResult *QueryResult) 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 QueryResult", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Result":
			// *mproto.QueryResult
			if kind != bson.Null {
				queryResult.Result = new(mproto.QueryResult)
				(*queryResult.Result).UnmarshalBson(buf, kind)
			}
		case "Session":
			// *Session
			if kind != bson.Null {
				queryResult.Session = new(Session)
				(*queryResult.Session).UnmarshalBson(buf, kind)
			}
		case "Error":
			queryResult.Error = bson.DecodeString(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
Ejemplo n.º 9
0
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
}
Ejemplo n.º 10
0
// 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)
		}
	}
}
Ejemplo n.º 11
0
// UnmarshalBson unmarshals BatchQueryShard from buf.
func (bqs *BatchQueryShard) 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 "Queries":
			bqs.Queries = tproto.DecodeQueriesBson(buf, kind)
		case "Keyspace":
			bqs.Keyspace = bson.DecodeString(buf, kind)
		case "Shards":
			bqs.Shards = bson.DecodeStringArray(buf, kind)
		case "TabletType":
			bqs.TabletType = topo.TabletType(bson.DecodeString(buf, kind))
		case "Session":
			if kind != bson.Null {
				bqs.Session = new(Session)
				bqs.Session.UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
		kind = bson.NextByte(buf)
	}
}
Ejemplo n.º 12
0
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)
	}
}
Ejemplo n.º 13
0
func (zkStat *ZkStat) UnmarshalBson(buf *bytes.Buffer) {
	bson.Next(buf, 4)

	kind := bson.NextByte(buf)
	for kind != bson.EOO {
		key := bson.ReadCString(buf)
		switch key {
		case "Czxid":
			zkStat.czxid = bson.DecodeInt64(buf, kind)
		case "Mzxid":
			zkStat.mzxid = bson.DecodeInt64(buf, kind)
		case "CTime":
			zkStat.cTime = bson.DecodeTime(buf, kind)
		case "MTime":
			zkStat.mTime = bson.DecodeTime(buf, kind)
		case "Version":
			zkStat.version = bson.DecodeInt(buf, kind)
		case "CVersion":
			zkStat.cVersion = bson.DecodeInt(buf, kind)
		case "AVersion":
			zkStat.aVersion = bson.DecodeInt(buf, kind)
		case "EphemeralOwner":
			zkStat.ephemeralOwner = bson.DecodeInt64(buf, kind)
		case "DataLength":
			zkStat.dataLength = bson.DecodeInt(buf, kind)
		case "NumChildren":
			zkStat.numChildren = bson.DecodeInt(buf, kind)
		case "Pzxid":
			zkStat.pzxid = bson.DecodeInt64(buf, kind)
		default:
			panic(bson.NewBsonError("Unrecognized tag %s for ZkStat", key))
		}
		kind = bson.NextByte(buf)
	}
}
Ejemplo n.º 14
0
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)
	}
}
Ejemplo n.º 15
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 "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)
		}
	}
}
Ejemplo n.º 16
0
// 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)
		}
	}
}
Ejemplo n.º 17
0
// UnmarshalBson unmarshals QueryResult from buf.
func (qr *QueryResult) UnmarshalBson(buf *bytes.Buffer) {
	bson.Next(buf, 4)

	kind := bson.NextByte(buf)
	for kind != bson.EOO {
		key := bson.ReadCString(buf)
		switch key {
		case "Fields":
			qr.Fields = mproto.DecodeFieldsBson(buf, kind)
		case "RowsAffected":
			qr.RowsAffected = bson.DecodeUint64(buf, kind)
		case "InsertId":
			qr.InsertId = bson.DecodeUint64(buf, kind)
		case "Rows":
			qr.Rows = mproto.DecodeRowsBson(buf, kind)
		case "Session":
			qr.Session = new(Session)
			qr.Session.UnmarshalBson(buf)
		case "Error":
			qr.Error = bson.DecodeString(buf, kind)
		default:
			panic(bson.NewBsonError("Unrecognized tag %s", key))
		}
		kind = bson.NextByte(buf)
	}
}
Ejemplo n.º 18
0
// 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)
	}
}
Ejemplo n.º 19
0
// UnmarshalBson unmarshals QueryResult from buf.
func (qr *QueryResult) 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 "Fields":
			qr.Fields = mproto.DecodeFieldsBson(buf, kind)
		case "RowsAffected":
			qr.RowsAffected = bson.DecodeUint64(buf, kind)
		case "InsertId":
			qr.InsertId = bson.DecodeUint64(buf, kind)
		case "Rows":
			qr.Rows = mproto.DecodeRowsBson(buf, kind)
		case "Session":
			if kind != bson.Null {
				qr.Session = new(Session)
				qr.Session.UnmarshalBson(buf, kind)
			}
		case "Error":
			qr.Error = bson.DecodeString(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
		kind = bson.NextByte(buf)
	}
}
Ejemplo n.º 20
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)
		}
	}
}
Ejemplo n.º 21
0
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)
	}
}
Ejemplo n.º 22
0
// 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)
		}
	}
}
Ejemplo n.º 23
0
// 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)
		}
	}
}
// 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)
		}
	}
}
Ejemplo n.º 25
0
func (ste *StreamEvent) UnmarshalBson(buf *bytes.Buffer) {
	bson.Next(buf, 4)

	kind := bson.NextByte(buf)
	for kind != bson.EOO {
		key := bson.ReadCString(buf)
		switch key {
		case "Category":
			ste.Category = bson.DecodeString(buf, kind)
		case "TableName":
			ste.TableName = bson.DecodeString(buf, kind)
		case "PKColNames":
			ste.PKColNames = bson.DecodeStringArray(buf, kind)
		case "PKValues":
			ste.PKValues = UnmarshalPKValuesBson(buf, kind)
		case "Sql":
			ste.Sql = bson.DecodeString(buf, kind)
		case "Timestamp":
			ste.Timestamp = bson.DecodeInt64(buf, kind)
		case "GroupId":
			ste.GroupId = bson.DecodeInt64(buf, kind)
		default:
			panic(bson.NewBsonError("Unrecognized tag %s", key))
		}
		kind = bson.NextByte(buf)
	}
}
Ejemplo n.º 26
0
// 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)
		}
	}
}
Ejemplo n.º 27
0
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)
	}
}
Ejemplo n.º 28
0
// 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
}
Ejemplo n.º 29
0
// UnmarshalBson bson-decodes into ReplicationPosition.
func (rp *ReplicationPosition) 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 ReplicationPosition", 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 value 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 ReplicationPosition"))
	}

	// Parse the value.
	var err error
	*rp, err = ParseReplicationPosition(flavor, value)
	if err != nil {
		panic(bson.NewBsonError("invalid value %#v for ReplicationPosition: %v", value, err))
	}
}
Ejemplo n.º 30
0
// UnmarshalBson bson-decodes into GetEndPointsArgs.
func (getEndPointsArgs *GetEndPointsArgs) 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 GetEndPointsArgs", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Cell":
			getEndPointsArgs.Cell = bson.DecodeString(buf, kind)
		case "Keyspace":
			getEndPointsArgs.Keyspace = bson.DecodeString(buf, kind)
		case "Shard":
			getEndPointsArgs.Shard = bson.DecodeString(buf, kind)
		case "TabletType":
			getEndPointsArgs.TabletType.UnmarshalBson(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}