func encodeRowsBson(rows [][]sqltypes.Value, key string, buf *bytes2.ChunkedWriter) { bson.EncodePrefix(buf, bson.Array, key) lenWriter := bson.NewLenWriter(buf) for i, v := range rows { encodeRowBson(v, bson.Itoa(i), buf) } buf.WriteByte(0) lenWriter.RecordLen() }
func (kr *KeyRange) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) bson.EncodeString(buf, "Start", string(kr.Start)) bson.EncodeString(buf, "End", string(kr.End)) buf.WriteByte(0) lenWriter.RecordLen() }
func encodeFieldsBson(fields []Field, key string, buf *bytes2.ChunkedWriter) { bson.EncodePrefix(buf, bson.Array, key) lenWriter := bson.NewLenWriter(buf) for i, v := range fields { MarshalFieldBson(v, bson.Itoa(i), buf) } buf.WriteByte(0) lenWriter.RecordLen() }
func EncodeBindVariablesBson(buf *bytes2.ChunkedWriter, key string, bindVars map[string]interface{}) { bson.EncodePrefix(buf, bson.Object, key) lenWriter := bson.NewLenWriter(buf) for k, v := range bindVars { bson.EncodeField(buf, k, v) } buf.WriteByte(0) lenWriter.RecordLen() }
func (req *RequestBson) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) bson.EncodeString(buf, "ServiceMethod", req.ServiceMethod) bson.EncodeInt64(buf, "Seq", int64(req.Seq)) buf.WriteByte(0) lenWriter.RecordLen() }
func (bdq *BoundQuery) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) bson.EncodeString(buf, "Sql", bdq.Sql) EncodeBindVariablesBson(buf, "BindVariables", bdq.BindVariables) buf.WriteByte(0) lenWriter.RecordLen() }
func MarshalFieldBson(field Field, key string, buf *bytes2.ChunkedWriter) { bson.EncodePrefix(buf, bson.Object, key) lenWriter := bson.NewLenWriter(buf) bson.EncodeString(buf, "Name", field.Name) bson.EncodeInt64(buf, "Type", field.Type) buf.WriteByte(0) lenWriter.RecordLen() }
func EncodeResultsBson(results []eproto.QueryResult, key string, buf *bytes2.ChunkedWriter) { bson.EncodePrefix(buf, bson.Array, key) lenWriter := bson.NewLenWriter(buf) for i, v := range results { bson.EncodePrefix(buf, bson.Object, bson.Itoa(i)) v.MarshalBson(buf) } buf.WriteByte(0) lenWriter.RecordLen() }
func EncodeQueriesBson(queries []BoundQuery, key string, buf *bytes2.ChunkedWriter) { bson.EncodePrefix(buf, bson.Array, key) lenWriter := bson.NewLenWriter(buf) for i, v := range queries { bson.EncodePrefix(buf, bson.Object, bson.Itoa(i)) v.MarshalBson(buf) } buf.WriteByte(0) lenWriter.RecordLen() }
func (session *Session) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) bson.EncodeInt64(buf, "TransactionId", session.TransactionId) bson.EncodeInt64(buf, "ConnectionId", session.ConnectionId) bson.EncodeInt64(buf, "SessionId", session.SessionId) buf.WriteByte(0) lenWriter.RecordLen() }
func (qr *QueryResult) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) encodeFieldsBson(qr.Fields, "Fields", buf) bson.EncodeInt64(buf, "RowsAffected", int64(qr.RowsAffected)) bson.EncodeInt64(buf, "InsertId", int64(qr.InsertId)) encodeRowsBson(qr.Rows, "Rows", buf) buf.WriteByte(0) lenWriter.RecordLen() }
func (ql *QueryList) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) EncodeQueriesBson(ql.Queries, "Queries", buf) bson.EncodeInt64(buf, "TransactionId", ql.TransactionId) bson.EncodeInt64(buf, "ConnectionId", ql.ConnectionId) bson.EncodeInt64(buf, "SessionId", ql.SessionId) buf.WriteByte(0) lenWriter.RecordLen() }
func (query *Query) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) bson.EncodeString(buf, "Sql", query.Sql) EncodeBindVariablesBson(buf, "BindVariables", query.BindVariables) bson.EncodeInt64(buf, "TransactionId", query.TransactionId) bson.EncodeInt64(buf, "ConnectionId", query.ConnectionId) bson.EncodeInt64(buf, "SessionId", query.SessionId) buf.WriteByte(0) lenWriter.RecordLen() }
func encodeRowBson(row []sqltypes.Value, key string, buf *bytes2.ChunkedWriter) { bson.EncodePrefix(buf, bson.Array, key) lenWriter := bson.NewLenWriter(buf) for i, v := range row { if v.IsNull() { bson.EncodePrefix(buf, bson.Null, bson.Itoa(i)) } else { bson.EncodeBinary(buf, bson.Itoa(i), v.Raw()) } } buf.WriteByte(0) lenWriter.RecordLen() }
func (qrl *QueryResultList) MarshalBson(buf *bytes2.ChunkedWriter) { lenWriter := bson.NewLenWriter(buf) EncodeResultsBson(qrl.List, "List", buf) buf.WriteByte(0) lenWriter.RecordLen() }