forked from dolthub/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_ids_query_bson.go
132 lines (123 loc) · 3.97 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// 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"
tproto "github.com/youtube/vitess/go/vt/tabletserver/proto"
)
// MarshalBson bson-encodes EntityIdsQuery.
func (entityIdsQuery *EntityIdsQuery) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// *tproto.CallerID
if entityIdsQuery.CallerID == nil {
bson.EncodePrefix(buf, bson.Null, "CallerID")
} else {
(*entityIdsQuery.CallerID).MarshalBson(buf, "CallerID")
}
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)
// []EntityId
{
bson.EncodePrefix(buf, bson.Array, "EntityKeyspaceIDs")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range entityIdsQuery.EntityKeyspaceIDs {
_v2.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
entityIdsQuery.TabletType.MarshalBson(buf, "TabletType")
// *Session
if entityIdsQuery.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*entityIdsQuery.Session).MarshalBson(buf, "Session")
}
bson.EncodeBool(buf, "NotInTransaction", entityIdsQuery.NotInTransaction)
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 "CallerID":
// *tproto.CallerID
if kind != bson.Null {
entityIdsQuery.CallerID = new(tproto.CallerID)
(*entityIdsQuery.CallerID).UnmarshalBson(buf, kind)
}
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)
}
case "NotInTransaction":
entityIdsQuery.NotInTransaction = bson.DecodeBool(buf, kind)
default:
bson.Skip(buf, kind)
}
}
}