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

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Sql":
			keyRangeQuery.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 keyRangeQuery.BindVariables", kind))
				}
				bson.Next(buf, 4)
				keyRangeQuery.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)
					keyRangeQuery.BindVariables[_k] = _v1
				}
			}
		case "Keyspace":
			keyRangeQuery.Keyspace = bson.DecodeString(buf, kind)
		case "KeyRanges":
			// []kproto.KeyRange
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for keyRangeQuery.KeyRanges", kind))
				}
				bson.Next(buf, 4)
				keyRangeQuery.KeyRanges = make([]kproto.KeyRange, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 kproto.KeyRange
					_v2.UnmarshalBson(buf, kind)
					keyRangeQuery.KeyRanges = append(keyRangeQuery.KeyRanges, _v2)
				}
			}
		case "TabletType":
			keyRangeQuery.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				keyRangeQuery.Session = new(Session)
				(*keyRangeQuery.Session).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
// 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)
		}
	}
}
// 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)
		}
	}
}
Beispiel #4
0
// UnmarshalBson bson-decodes into QueryShard.
func (queryShard *QueryShard) 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 QueryShard", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Sql":
			queryShard.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 queryShard.BindVariables", kind))
				}
				bson.Next(buf, 4)
				queryShard.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)
					queryShard.BindVariables[_k] = _v1
				}
			}
		case "Keyspace":
			queryShard.Keyspace = bson.DecodeString(buf, kind)
		case "Shards":
			// []string
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for queryShard.Shards", kind))
				}
				bson.Next(buf, 4)
				queryShard.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)
					queryShard.Shards = append(queryShard.Shards, _v2)
				}
			}
		case "TabletType":
			queryShard.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				queryShard.Session = new(Session)
				(*queryShard.Session).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
// 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)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
Beispiel #6
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)
		}
	}
}
Beispiel #7
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)
		}
	}
}
Beispiel #8
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
}
Beispiel #9
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)
		}
	}
}
// 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)
		}
	}
}
Beispiel #11
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)
		}
	}
}
Beispiel #12
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))
	}
}
Beispiel #13
0
// UnmarshalBson bson-decodes into TabletType.
func (tabletType *TabletType) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	if kind == bson.EOO {
		bson.Next(buf, 4)
		kind = bson.NextByte(buf)
		bson.ReadCString(buf)
	}
	*tabletType = TabletType(bson.DecodeString(buf, kind))
}
Beispiel #14
0
// UnmarshalBson bson-decodes into KeyspaceId.
func (keyspaceId *KeyspaceId) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	if kind == bson.EOO {
		bson.Next(buf, 4)
		kind = bson.NextByte(buf)
		bson.ReadCString(buf)
	}
	*keyspaceId = KeyspaceId(bson.DecodeString(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)
		}
	}
}
Beispiel #16
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)
		}
	}
}
Beispiel #17
0
func (resp *ResponseBson) UnmarshalBson(buf *bytes.Buffer, kind byte) {
	bson.VerifyObject(kind)
	bson.Next(buf, 4)

	kind = bson.NextByte(buf)
	for kind != bson.EOO {
		key := bson.ReadCString(buf)
		switch key {
		case "ServiceMethod":
			resp.ServiceMethod = bson.DecodeString(buf, kind)
		case "Seq":
			resp.Seq = bson.DecodeUint64(buf, kind)
		case "Error":
			resp.Error = bson.DecodeString(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
		kind = bson.NextByte(buf)
	}
}
Beispiel #18
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 "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)
		}
	}
}
Beispiel #19
0
// UnmarshalBson bson-decodes into ZkPath.
func (zkPath *ZkPath) 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 ZkPath", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Path":
			zkPath.Path = bson.DecodeString(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
Beispiel #20
0
// UnmarshalBson bson-decodes into Field.
func (field *Field) 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 Field", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Name":
			field.Name = bson.DecodeString(buf, kind)
		case "Type":
			field.Type = bson.DecodeInt64(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
// UnmarshalBson bson-decodes into EntityIdsQuery.
func (entityIdsQuery *EntityIdsQuery) 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 EntityIdsQuery", kind))
	}
	bson.Next(buf, 4)

	for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
		switch bson.ReadCString(buf) {
		case "Sql":
			entityIdsQuery.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 entityIdsQuery.BindVariables", kind))
				}
				bson.Next(buf, 4)
				entityIdsQuery.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)
					entityIdsQuery.BindVariables[_k] = _v1
				}
			}
		case "Keyspace":
			entityIdsQuery.Keyspace = bson.DecodeString(buf, kind)
		case "EntityColumnName":
			entityIdsQuery.EntityColumnName = bson.DecodeString(buf, kind)
		case "EntityKeyspaceIDs":
			// []EntityId
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for entityIdsQuery.EntityKeyspaceIDs", kind))
				}
				bson.Next(buf, 4)
				entityIdsQuery.EntityKeyspaceIDs = make([]EntityId, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 EntityId
					_v2.UnmarshalBson(buf, kind)
					entityIdsQuery.EntityKeyspaceIDs = append(entityIdsQuery.EntityKeyspaceIDs, _v2)
				}
			}
		case "TabletType":
			entityIdsQuery.TabletType.UnmarshalBson(buf, kind)
		case "Session":
			// *Session
			if kind != bson.Null {
				entityIdsQuery.Session = new(Session)
				(*entityIdsQuery.Session).UnmarshalBson(buf, kind)
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
Beispiel #22
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)
		}
	}
}
Beispiel #23
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 "Map":
			// map[string]string
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.Map", kind))
				}
				bson.Next(buf, 4)
				myType.Map = make(map[string]string)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v1 string
					_v1 = bson.DecodeString(buf, kind)
					myType.Map[_k] = _v1
				}
			}
		case "MapBytes":
			// map[string][]byte
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapBytes", kind))
				}
				bson.Next(buf, 4)
				myType.MapBytes = make(map[string][]byte)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v2 []byte
					_v2 = bson.DecodeBinary(buf, kind)
					myType.MapBytes[_k] = _v2
				}
			}
		case "MapPtr":
			// map[string]*string
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapPtr", kind))
				}
				bson.Next(buf, 4)
				myType.MapPtr = make(map[string]*string)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v3 *string
					// *string
					if kind != bson.Null {
						_v3 = new(string)
						(*_v3) = bson.DecodeString(buf, kind)
					}
					myType.MapPtr[_k] = _v3
				}
			}
		case "MapSlice":
			// map[string][]string
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapSlice", kind))
				}
				bson.Next(buf, 4)
				myType.MapSlice = make(map[string][]string)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(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.MapSlice[_k] = _v4
				}
			}
		case "MapMap":
			// map[string]map[string]int64
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapMap", kind))
				}
				bson.Next(buf, 4)
				myType.MapMap = make(map[string]map[string]int64)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(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.MapMap[_k] = _v6
				}
			}
		case "MapCustom":
			// map[string]Custom
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapCustom", kind))
				}
				bson.Next(buf, 4)
				myType.MapCustom = make(map[string]Custom)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v8 Custom
					_v8.UnmarshalBson(buf, kind)
					myType.MapCustom[_k] = _v8
				}
			}
		case "MapCustomPtr":
			// map[string]*Custom
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapCustomPtr", kind))
				}
				bson.Next(buf, 4)
				myType.MapCustomPtr = make(map[string]*Custom)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v9 *Custom
					// *Custom
					if kind != bson.Null {
						_v9 = new(Custom)
						(*_v9).UnmarshalBson(buf, kind)
					}
					myType.MapCustomPtr[_k] = _v9
				}
			}
		case "CustomMap":
			// map[Custom]string
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.CustomMap", kind))
				}
				bson.Next(buf, 4)
				myType.CustomMap = make(map[Custom]string)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := Custom(bson.ReadCString(buf))
					var _v10 string
					_v10 = bson.DecodeString(buf, kind)
					myType.CustomMap[_k] = _v10
				}
			}
		case "MapExternal":
			// map[pkg.Custom]string
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for myType.MapExternal", kind))
				}
				bson.Next(buf, 4)
				myType.MapExternal = make(map[pkg.Custom]string)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := pkg.Custom(bson.ReadCString(buf))
					var _v11 string
					_v11 = bson.DecodeString(buf, kind)
					myType.MapExternal[_k] = _v11
				}
			}
		default:
			bson.Skip(buf, kind)
		}
	}
}
Beispiel #24
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 "Shards":
			// []SrvShard
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for srvKeyspace.Shards", kind))
				}
				bson.Next(buf, 4)
				srvKeyspace.Shards = make([]SrvShard, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 SrvShard
					_v2.UnmarshalBson(buf, kind)
					srvKeyspace.Shards = append(srvKeyspace.Shards, _v2)
				}
			}
		case "TabletTypes":
			// []TabletType
			if kind != bson.Null {
				if kind != bson.Array {
					panic(bson.NewBsonError("unexpected kind %v for srvKeyspace.TabletTypes", kind))
				}
				bson.Next(buf, 4)
				srvKeyspace.TabletTypes = make([]TabletType, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v3 TabletType
					_v3.UnmarshalBson(buf, kind)
					srvKeyspace.TabletTypes = append(srvKeyspace.TabletTypes, _v3)
				}
			}
		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 _v4 string
					_v4 = bson.DecodeString(buf, kind)
					srvKeyspace.ServedFrom[_k] = _v4
				}
			}
		case "SplitShardCount":
			srvKeyspace.SplitShardCount = bson.DecodeInt32(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}