// 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) } } }
// 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 "Float64": myType.Float64 = bson.DecodeFloat64(buf, kind) case "String": myType.String = bson.DecodeString(buf, kind) case "Bool": myType.Bool = bson.DecodeBool(buf, kind) case "Int64": myType.Int64 = bson.DecodeInt64(buf, kind) case "Int32": myType.Int32 = bson.DecodeInt32(buf, kind) case "Int": myType.Int = bson.DecodeInt(buf, kind) case "Uint64": myType.Uint64 = bson.DecodeUint64(buf, kind) case "Uint32": myType.Uint32 = bson.DecodeUint32(buf, kind) case "Uint": myType.Uint = bson.DecodeUint(buf, kind) case "Bytes": myType.Bytes = bson.DecodeBinary(buf, kind) case "Time": myType.Time = bson.DecodeTime(buf, kind) case "Interface": myType.Interface = bson.DecodeInterface(buf, kind) default: bson.Skip(buf, kind) } } }