// 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)
		}
	}
}
// 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":
			// []key.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([]key.KeyspaceId, 0, 8)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					bson.SkipIndex(buf)
					var _v2 key.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)
			}
		case "NotInTransaction":
			keyspaceIdBatchQuery.NotInTransaction = bson.DecodeBool(buf, kind)
		default:
			bson.Skip(buf, kind)
		}
	}
}
Beispiel #3
0
// uint64FromKeyspaceId returns a 64 bits hex number as a string
// (in the form of 0x0123456789abcdef) from the provided keyspaceId
func uint64FromKeyspaceId(keyspaceId key.KeyspaceId) string {
	hex := string(keyspaceId.Hex())
	return "0x" + hex + strings.Repeat("0", 16-len(hex))
}
// 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 "EntityKeyspaceIdMap":
			// map[string]kproto.KeyspaceId
			if kind != bson.Null {
				if kind != bson.Object {
					panic(bson.NewBsonError("unexpected kind %v for entityIdsQuery.EntityKeyspaceIdMap", kind))
				}
				bson.Next(buf, 4)
				entityIdsQuery.EntityKeyspaceIdMap = make(map[string]kproto.KeyspaceId)
				for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
					_k := bson.ReadCString(buf)
					var _v2 kproto.KeyspaceId
					_v2.UnmarshalBson(buf, kind)
					entityIdsQuery.EntityKeyspaceIdMap[_k] = _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)
		}
	}
}