forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_ids_query_bson.go
117 lines (108 loc) · 3.47 KB
/
entity_ids_query_bson.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package proto
// DO NOT EDIT.
// FILE GENERATED BY BSONGEN.
import (
"bytes"
"github.com/youtube/vitess/go/bson"
"github.com/youtube/vitess/go/bytes2"
kproto "github.com/youtube/vitess/go/vt/key"
)
// MarshalBson bson-encodes EntityIdsQuery.
func (entityIdsQuery *EntityIdsQuery) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Sql", entityIdsQuery.Sql)
// map[string]interface{}
{
bson.EncodePrefix(buf, bson.Object, "BindVariables")
lenWriter := bson.NewLenWriter(buf)
for _k, _v1 := range entityIdsQuery.BindVariables {
bson.EncodeInterface(buf, _k, _v1)
}
lenWriter.Close()
}
bson.EncodeString(buf, "Keyspace", entityIdsQuery.Keyspace)
bson.EncodeString(buf, "EntityColumnName", entityIdsQuery.EntityColumnName)
// map[string]kproto.KeyspaceId
{
bson.EncodePrefix(buf, bson.Object, "EntityKeyspaceIdMap")
lenWriter := bson.NewLenWriter(buf)
for _k, _v2 := range entityIdsQuery.EntityKeyspaceIdMap {
_v2.MarshalBson(buf, _k)
}
lenWriter.Close()
}
entityIdsQuery.TabletType.MarshalBson(buf, "TabletType")
// *Session
if entityIdsQuery.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*entityIdsQuery.Session).MarshalBson(buf, "Session")
}
lenWriter.Close()
}
// 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)
}
}
}