本文整理匯總了Golang中github.com/henryanand/vitess/go/bson.EncodePrefix函數的典型用法代碼示例。如果您正苦於以下問題:Golang EncodePrefix函數的具體用法?Golang EncodePrefix怎麽用?Golang EncodePrefix使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EncodePrefix函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MarshalBson
// MarshalBson bson-encodes KeyRangeQuery.
func (keyRangeQuery *KeyRangeQuery) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Sql", keyRangeQuery.Sql)
// map[string]interface{}
{
bson.EncodePrefix(buf, bson.Object, "BindVariables")
lenWriter := bson.NewLenWriter(buf)
for _k, _v1 := range keyRangeQuery.BindVariables {
bson.EncodeInterface(buf, _k, _v1)
}
lenWriter.Close()
}
bson.EncodeString(buf, "Keyspace", keyRangeQuery.Keyspace)
// []kproto.KeyRange
{
bson.EncodePrefix(buf, bson.Array, "KeyRanges")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range keyRangeQuery.KeyRanges {
_v2.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
keyRangeQuery.TabletType.MarshalBson(buf, "TabletType")
// *Session
if keyRangeQuery.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*keyRangeQuery.Session).MarshalBson(buf, "Session")
}
lenWriter.Close()
}
示例2: MarshalBson
// MarshalBson bson-encodes BatchQueryShard.
func (batchQueryShard *BatchQueryShard) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// []tproto.BoundQuery
{
bson.EncodePrefix(buf, bson.Array, "Queries")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range batchQueryShard.Queries {
_v1.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
bson.EncodeString(buf, "Keyspace", batchQueryShard.Keyspace)
// []string
{
bson.EncodePrefix(buf, bson.Array, "Shards")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range batchQueryShard.Shards {
bson.EncodeString(buf, bson.Itoa(_i), _v2)
}
lenWriter.Close()
}
batchQueryShard.TabletType.MarshalBson(buf, "TabletType")
// *Session
if batchQueryShard.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*batchQueryShard.Session).MarshalBson(buf, "Session")
}
lenWriter.Close()
}
示例3: MarshalBson
// MarshalBson bson-encodes KeyspaceIdBatchQuery.
func (keyspaceIdBatchQuery *KeyspaceIdBatchQuery) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// []tproto.BoundQuery
{
bson.EncodePrefix(buf, bson.Array, "Queries")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range keyspaceIdBatchQuery.Queries {
_v1.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
bson.EncodeString(buf, "Keyspace", keyspaceIdBatchQuery.Keyspace)
// []kproto.KeyspaceId
{
bson.EncodePrefix(buf, bson.Array, "KeyspaceIds")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range keyspaceIdBatchQuery.KeyspaceIds {
_v2.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
keyspaceIdBatchQuery.TabletType.MarshalBson(buf, "TabletType")
// *Session
if keyspaceIdBatchQuery.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*keyspaceIdBatchQuery.Session).MarshalBson(buf, "Session")
}
lenWriter.Close()
}
示例4: MarshalBson
// MarshalBson bson-encodes SrvShard.
func (srvShard *SrvShard) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Name", srvShard.Name)
srvShard.KeyRange.MarshalBson(buf, "KeyRange")
// []TabletType
{
bson.EncodePrefix(buf, bson.Array, "ServedTypes")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range srvShard.ServedTypes {
_v1.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
bson.EncodeString(buf, "MasterCell", srvShard.MasterCell)
// []TabletType
{
bson.EncodePrefix(buf, bson.Array, "TabletTypes")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range srvShard.TabletTypes {
_v2.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
lenWriter.Close()
}
示例5: MarshalBson
// 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)
// []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")
}
lenWriter.Close()
}
示例6: MarshalBson
// MarshalBson bson-encodes QueryResult.
func (queryResult *QueryResult) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// []Field
{
bson.EncodePrefix(buf, bson.Array, "Fields")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range queryResult.Fields {
_v1.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
bson.EncodeUint64(buf, "RowsAffected", queryResult.RowsAffected)
bson.EncodeUint64(buf, "InsertId", queryResult.InsertId)
// [][]sqltypes.Value
{
bson.EncodePrefix(buf, bson.Array, "Rows")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range queryResult.Rows {
// []sqltypes.Value
{
bson.EncodePrefix(buf, bson.Array, bson.Itoa(_i))
lenWriter := bson.NewLenWriter(buf)
for _i, _v3 := range _v2 {
_v3.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
}
lenWriter.Close()
}
lenWriter.Close()
}
示例7: MarshalBson
// MarshalBson bson-encodes QueryShard.
func (queryShard *QueryShard) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Sql", queryShard.Sql)
// map[string]interface{}
{
bson.EncodePrefix(buf, bson.Object, "BindVariables")
lenWriter := bson.NewLenWriter(buf)
for _k, _v1 := range queryShard.BindVariables {
bson.EncodeInterface(buf, _k, _v1)
}
lenWriter.Close()
}
bson.EncodeString(buf, "Keyspace", queryShard.Keyspace)
// []string
{
bson.EncodePrefix(buf, bson.Array, "Shards")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range queryShard.Shards {
bson.EncodeString(buf, bson.Itoa(_i), _v2)
}
lenWriter.Close()
}
queryShard.TabletType.MarshalBson(buf, "TabletType")
// *Session
if queryShard.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*queryShard.Session).MarshalBson(buf, "Session")
}
lenWriter.Close()
}
示例8: MarshalBson
// MarshalBson bson-encodes SrvKeyspace.
func (srvKeyspace *SrvKeyspace) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// map[TabletType]*KeyspacePartition
{
bson.EncodePrefix(buf, bson.Object, "Partitions")
lenWriter := bson.NewLenWriter(buf)
for _k, _v1 := range srvKeyspace.Partitions {
// *KeyspacePartition
if _v1 == nil {
bson.EncodePrefix(buf, bson.Null, string(_k))
} else {
(*_v1).MarshalBson(buf, string(_k))
}
}
lenWriter.Close()
}
// []SrvShard
{
bson.EncodePrefix(buf, bson.Array, "Shards")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range srvKeyspace.Shards {
_v2.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
// []TabletType
{
bson.EncodePrefix(buf, bson.Array, "TabletTypes")
lenWriter := bson.NewLenWriter(buf)
for _i, _v3 := range srvKeyspace.TabletTypes {
_v3.MarshalBson(buf, bson.Itoa(_i))
}
lenWriter.Close()
}
bson.EncodeString(buf, "ShardingColumnName", srvKeyspace.ShardingColumnName)
srvKeyspace.ShardingColumnType.MarshalBson(buf, "ShardingColumnType")
// map[TabletType]string
{
bson.EncodePrefix(buf, bson.Object, "ServedFrom")
lenWriter := bson.NewLenWriter(buf)
for _k, _v4 := range srvKeyspace.ServedFrom {
bson.EncodeString(buf, string(_k), _v4)
}
lenWriter.Close()
}
bson.EncodeInt32(buf, "SplitShardCount", srvKeyspace.SplitShardCount)
lenWriter.Close()
}
示例9: MarshalBson
// MarshalBson bson-encodes QueryResult.
func (queryResult *QueryResult) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// *mproto.QueryResult
if queryResult.Result == nil {
bson.EncodePrefix(buf, bson.Null, "Result")
} else {
(*queryResult.Result).MarshalBson(buf, "Result")
}
// *Session
if queryResult.Session == nil {
bson.EncodePrefix(buf, bson.Null, "Session")
} else {
(*queryResult.Session).MarshalBson(buf, "Session")
}
bson.EncodeString(buf, "Error", queryResult.Error)
lenWriter.Close()
}
示例10: MarshalBson
// MarshalBson bson-encodes ZkNodeV.
func (zkNodeV *ZkNodeV) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
// []*ZkNode
{
bson.EncodePrefix(buf, bson.Array, "Nodes")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range zkNodeV.Nodes {
// *ZkNode
if _v1 == nil {
bson.EncodePrefix(buf, bson.Null, bson.Itoa(_i))
} else {
(*_v1).MarshalBson(buf, bson.Itoa(_i))
}
}
lenWriter.Close()
}
lenWriter.Close()
}
示例11: MarshalBson
func (v Value) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
if key == "" {
lenWriter := bson.NewLenWriter(buf)
defer lenWriter.Close()
key = bson.MAGICTAG
}
if v.IsNull() {
bson.EncodePrefix(buf, bson.Null, key)
} else {
bson.EncodeBinary(buf, key, v.Raw())
}
}
示例12: MarshalBson
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
myType.Cust1.MarshalBson(buf, "Cust1")
// *Custom1
if myType.Cust2 == nil {
bson.EncodePrefix(buf, bson.Null, "Cust2")
} else {
(*myType.Cust2).MarshalBson(buf, "Cust2")
}
myType.Cust3.MarshalBson(buf, "Cust3")
// *pkg.Custom2
if myType.Cust4 == nil {
bson.EncodePrefix(buf, bson.Null, "Cust4")
} else {
(*myType.Cust4).MarshalBson(buf, "Cust4")
}
lenWriter.Close()
}
示例13: MarshalBson
// MarshalBson bson-encodes Session.
func (session *Session) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeBool(buf, "InTransaction", session.InTransaction)
// []*ShardSession
{
bson.EncodePrefix(buf, bson.Array, "ShardSessions")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range session.ShardSessions {
// *ShardSession
if _v1 == nil {
bson.EncodePrefix(buf, bson.Null, bson.Itoa(_i))
} else {
(*_v1).MarshalBson(buf, bson.Itoa(_i))
}
}
lenWriter.Close()
}
lenWriter.Close()
}
示例14: MarshalBson
// MarshalBson bson-encodes StreamEvent.
func (streamEvent *StreamEvent) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Category", streamEvent.Category)
bson.EncodeString(buf, "TableName", streamEvent.TableName)
// []string
{
bson.EncodePrefix(buf, bson.Array, "PKColNames")
lenWriter := bson.NewLenWriter(buf)
for _i, _v1 := range streamEvent.PKColNames {
bson.EncodeString(buf, bson.Itoa(_i), _v1)
}
lenWriter.Close()
}
// [][]interface{}
{
bson.EncodePrefix(buf, bson.Array, "PKValues")
lenWriter := bson.NewLenWriter(buf)
for _i, _v2 := range streamEvent.PKValues {
// []interface{}
{
bson.EncodePrefix(buf, bson.Array, bson.Itoa(_i))
lenWriter := bson.NewLenWriter(buf)
for _i, _v3 := range _v2 {
bson.EncodeInterface(buf, bson.Itoa(_i), _v3)
}
lenWriter.Close()
}
}
lenWriter.Close()
}
bson.EncodeString(buf, "Sql", streamEvent.Sql)
bson.EncodeInt64(buf, "Timestamp", streamEvent.Timestamp)
streamEvent.GTIDField.MarshalBson(buf, "GTIDField")
lenWriter.Close()
}
示例15: MarshalBson
// MarshalBson bson-encodes Statement.
func (statement *Statement) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeInt(buf, "Category", statement.Category)
// *mproto.Charset
if statement.Charset == nil {
bson.EncodePrefix(buf, bson.Null, "Charset")
} else {
(*statement.Charset).MarshalBson(buf, "Charset")
}
bson.EncodeBinary(buf, "Sql", statement.Sql)
lenWriter.Close()
}