// 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()
}
// 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()
}
// 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()
}
Example #4
0
// 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()
}
// 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()
}
Example #6
0
// 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()
}
Example #7
0
// 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()
}
Example #8
0
// 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()
}
Example #9
0
// 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()
}
Example #10
0
// 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()
}
Example #11
0
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())
	}
}
Example #12
0
// 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()
}
Example #13
0
// 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()
}
Example #14
0
// 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()
}
Example #15
0
// 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()
}
Example #16
0
// MarshalBson bson-encodes Query.
func (query *Query) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "Sql", query.Sql)
	// map[string]interface{}
	{
		bson.EncodePrefix(buf, bson.Object, "BindVariables")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v1 := range query.BindVariables {
			bson.EncodeInterface(buf, _k, _v1)
		}
		lenWriter.Close()
	}
	query.TabletType.MarshalBson(buf, "TabletType")
	// *Session
	if query.Session == nil {
		bson.EncodePrefix(buf, bson.Null, "Session")
	} else {
		(*query.Session).MarshalBson(buf, "Session")
	}

	lenWriter.Close()
}
// MarshalBson bson-encodes SrvKeyspaceNames.
func (srvKeyspaceNames *SrvKeyspaceNames) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []string
	{
		bson.EncodePrefix(buf, bson.Array, "Entries")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range srvKeyspaceNames.Entries {
			bson.EncodeString(buf, bson.Itoa(_i), _v1)
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
// MarshalBson bson-encodes BlpPositionList.
func (blpPositionList *BlpPositionList) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []BlpPosition
	{
		bson.EncodePrefix(buf, bson.Array, "Entries")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range blpPositionList.Entries {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
Example #19
0
// MarshalBson bson-encodes ZkPathV.
func (zkPathV *ZkPathV) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []string
	{
		bson.EncodePrefix(buf, bson.Array, "Paths")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range zkPathV.Paths {
			bson.EncodeString(buf, bson.Itoa(_i), _v1)
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
// MarshalBson bson-encodes QueryResultList.
func (queryResultList *QueryResultList) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []mproto.QueryResult
	{
		bson.EncodePrefix(buf, bson.Array, "List")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range queryResultList.List {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
// MarshalBson bson-encodes KeyspacePartition.
func (keyspacePartition *KeyspacePartition) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []SrvShard
	{
		bson.EncodePrefix(buf, bson.Array, "Shards")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range keyspacePartition.Shards {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
Example #22
0
// MarshalBson bson-encodes BoundQuery.
func (boundQuery *BoundQuery) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "Sql", boundQuery.Sql)
	// map[string]interface{}
	{
		bson.EncodePrefix(buf, bson.Object, "BindVariables")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v1 := range boundQuery.BindVariables {
			bson.EncodeInterface(buf, _k, _v1)
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
Example #23
0
// MarshalBson bson-encodes QueryList.
func (queryList *QueryList) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []BoundQuery
	{
		bson.EncodePrefix(buf, bson.Array, "Queries")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range queryList.Queries {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}
	bson.EncodeInt64(buf, "SessionId", queryList.SessionId)
	bson.EncodeInt64(buf, "TransactionId", queryList.TransactionId)

	lenWriter.Close()
}
// MarshalBson bson-encodes BinlogTransaction.
func (binlogTransaction *BinlogTransaction) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []Statement
	{
		bson.EncodePrefix(buf, bson.Array, "Statements")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range binlogTransaction.Statements {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}
	bson.EncodeInt64(buf, "Timestamp", binlogTransaction.Timestamp)
	binlogTransaction.GTIDField.MarshalBson(buf, "GTIDField")

	lenWriter.Close()
}
Example #25
0
// MarshalBson bson-encodes ZkNode.
func (zkNode *ZkNode) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "Path", zkNode.Path)
	bson.EncodeString(buf, "Data", zkNode.Data)
	zkNode.Stat.MarshalBson(buf, "Stat")
	// []string
	{
		bson.EncodePrefix(buf, bson.Array, "Children")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range zkNode.Children {
			bson.EncodeString(buf, bson.Itoa(_i), _v1)
		}
		lenWriter.Close()
	}
	bson.EncodeBool(buf, "Cached", zkNode.Cached)
	bson.EncodeBool(buf, "Stale", zkNode.Stale)

	lenWriter.Close()
}
Example #26
0
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// *int64
	if myType.Ptr == nil {
		bson.EncodePrefix(buf, bson.Null, "Ptr")
	} else {
		bson.EncodeInt64(buf, "Ptr", (*myType.Ptr))
	}
	// **int64
	if myType.PtrPtr == nil {
		bson.EncodePrefix(buf, bson.Null, "PtrPtr")
	} else {
		// *int64
		if (*myType.PtrPtr) == nil {
			bson.EncodePrefix(buf, bson.Null, "PtrPtr")
		} else {
			bson.EncodeInt64(buf, "PtrPtr", (*(*myType.PtrPtr)))
		}
	}
	// *[]byte
	if myType.PtrBytes == nil {
		bson.EncodePrefix(buf, bson.Null, "PtrBytes")
	} else {
		bson.EncodeBinary(buf, "PtrBytes", (*myType.PtrBytes))
	}
	// *[]int64
	if myType.PtrSlice == nil {
		bson.EncodePrefix(buf, bson.Null, "PtrSlice")
	} else {
		// []int64
		{
			bson.EncodePrefix(buf, bson.Array, "PtrSlice")
			lenWriter := bson.NewLenWriter(buf)
			for _i, _v1 := range *myType.PtrSlice {
				bson.EncodeInt64(buf, bson.Itoa(_i), _v1)
			}
			lenWriter.Close()
		}
	}
	// *map[string]int64
	if myType.PtrMap == nil {
		bson.EncodePrefix(buf, bson.Null, "PtrMap")
	} else {
		// map[string]int64
		{
			bson.EncodePrefix(buf, bson.Object, "PtrMap")
			lenWriter := bson.NewLenWriter(buf)
			for _k, _v2 := range *myType.PtrMap {
				bson.EncodeInt64(buf, _k, _v2)
			}
			lenWriter.Close()
		}
	}
	// *Custom
	if myType.PtrCustom == nil {
		bson.EncodePrefix(buf, bson.Null, "PtrCustom")
	} else {
		(*myType.PtrCustom).MarshalBson(buf, "PtrCustom")
	}

	lenWriter.Close()
}
Example #27
0
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// map[string]string
	{
		bson.EncodePrefix(buf, bson.Object, "Map")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v1 := range myType.Map {
			bson.EncodeString(buf, _k, _v1)
		}
		lenWriter.Close()
	}
	// map[string][]byte
	{
		bson.EncodePrefix(buf, bson.Object, "MapBytes")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v2 := range myType.MapBytes {
			bson.EncodeBinary(buf, _k, _v2)
		}
		lenWriter.Close()
	}
	// map[string]*string
	{
		bson.EncodePrefix(buf, bson.Object, "MapPtr")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v3 := range myType.MapPtr {
			// *string
			if _v3 == nil {
				bson.EncodePrefix(buf, bson.Null, _k)
			} else {
				bson.EncodeString(buf, _k, (*_v3))
			}
		}
		lenWriter.Close()
	}
	// map[string][]string
	{
		bson.EncodePrefix(buf, bson.Object, "MapSlice")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v4 := range myType.MapSlice {
			// []string
			{
				bson.EncodePrefix(buf, bson.Array, _k)
				lenWriter := bson.NewLenWriter(buf)
				for _i, _v5 := range _v4 {
					bson.EncodeString(buf, bson.Itoa(_i), _v5)
				}
				lenWriter.Close()
			}
		}
		lenWriter.Close()
	}
	// map[string]map[string]int64
	{
		bson.EncodePrefix(buf, bson.Object, "MapMap")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v6 := range myType.MapMap {
			// map[string]int64
			{
				bson.EncodePrefix(buf, bson.Object, _k)
				lenWriter := bson.NewLenWriter(buf)
				for _k, _v7 := range _v6 {
					bson.EncodeInt64(buf, _k, _v7)
				}
				lenWriter.Close()
			}
		}
		lenWriter.Close()
	}
	// map[string]Custom
	{
		bson.EncodePrefix(buf, bson.Object, "MapCustom")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v8 := range myType.MapCustom {
			_v8.MarshalBson(buf, _k)
		}
		lenWriter.Close()
	}
	// map[string]*Custom
	{
		bson.EncodePrefix(buf, bson.Object, "MapCustomPtr")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v9 := range myType.MapCustomPtr {
			// *Custom
			if _v9 == nil {
				bson.EncodePrefix(buf, bson.Null, _k)
			} else {
				(*_v9).MarshalBson(buf, _k)
			}
		}
		lenWriter.Close()
	}
	// map[Custom]string
	{
		bson.EncodePrefix(buf, bson.Object, "CustomMap")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v10 := range myType.CustomMap {
			bson.EncodeString(buf, string(_k), _v10)
		}
		lenWriter.Close()
	}
	// map[pkg.Custom]string
	{
		bson.EncodePrefix(buf, bson.Object, "MapExternal")
		lenWriter := bson.NewLenWriter(buf)
		for _k, _v11 := range myType.MapExternal {
			bson.EncodeString(buf, string(_k), _v11)
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}