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 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 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 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() }