Esempio n. 1
0
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")
	bson.EncodeStringArray(buf, "Children", zkNode.Children)
	bson.EncodeBool(buf, "Cached", zkNode.Cached)
	bson.EncodeBool(buf, "Stale", zkNode.Stale)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Esempio n. 2
0
// MarshalBson bson-encodes BatchQueryShard.
func (batchQueryShard *BatchQueryShard) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// *tproto.CallerID
	if batchQueryShard.CallerID == nil {
		bson.EncodePrefix(buf, bson.Null, "CallerID")
	} else {
		(*batchQueryShard.CallerID).MarshalBson(buf, "CallerID")
	}
	// []BoundShardQuery
	{
		bson.EncodePrefix(buf, bson.Array, "Queries")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range batchQueryShard.Queries {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}
	batchQueryShard.TabletType.MarshalBson(buf, "TabletType")
	bson.EncodeBool(buf, "AsTransaction", batchQueryShard.AsTransaction)
	// *Session
	if batchQueryShard.Session == nil {
		bson.EncodePrefix(buf, bson.Null, "Session")
	} else {
		(*batchQueryShard.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")
	}
	bson.EncodeBool(buf, "NotInTransaction", batchQueryShard.NotInTransaction)

	lenWriter.Close()
}
Esempio n. 4
0
// 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)
	// []key.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")
	}
	bson.EncodeBool(buf, "NotInTransaction", keyRangeQuery.NotInTransaction)

	lenWriter.Close()
}
Esempio n. 5
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")
	}
	bson.EncodeBool(buf, "NotInTransaction", queryShard.NotInTransaction)

	lenWriter.Close()
}
Esempio n. 6
0
// MarshalBson bson-encodes Query.
func (query *Query) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// *tproto.CallerID
	if query.CallerID == nil {
		bson.EncodePrefix(buf, bson.Null, "CallerID")
	} else {
		(*query.CallerID).MarshalBson(buf, "CallerID")
	}
	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")
	}
	bson.EncodeBool(buf, "NotInTransaction", query.NotInTransaction)

	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)
	// []key.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")
	}
	bson.EncodeBool(buf, "NotInTransaction", keyspaceIdBatchQuery.NotInTransaction)

	lenWriter.Close()
}
Esempio n. 8
0
// MarshalBson marshals Session into buf.
func (session *Session) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeBool(buf, "InTransaction", session.InTransaction)
	encodeShardSessionsBson(session.ShardSessions, "ShardSessions", buf)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Esempio n. 9
0
// MarshalBson marshals Session into buf.
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)
	encodeShardSessionsBson(session.ShardSessions, "ShardSessions", buf)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Esempio n. 10
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()
}
// MarshalBson bson-encodes A.
func (a *A) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "Name", a.Name)
	bson.EncodeTime(buf, "BirthDay", a.BirthDay)
	bson.EncodeString(buf, "Phone", a.Phone)
	bson.EncodeInt(buf, "Siblings", a.Siblings)
	bson.EncodeBool(buf, "Spouse", a.Spouse)
	bson.EncodeFloat64(buf, "Money", a.Money)

	lenWriter.Close()
}
Esempio n. 12
0
func (zkNode *ZkNode) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodePrefix(buf, bson.Binary, "Path")
	bson.EncodeString(buf, zkNode.Path)

	bson.EncodePrefix(buf, bson.Binary, "Data")
	bson.EncodeString(buf, zkNode.Data)

	bson.EncodePrefix(buf, bson.Object, "Stat")
	zkNode.Stat.MarshalBson(buf)

	bson.EncodeStringArray(buf, "Children", zkNode.Children)

	bson.EncodePrefix(buf, bson.Boolean, "Cached")
	bson.EncodeBool(buf, zkNode.Cached)

	bson.EncodePrefix(buf, bson.Boolean, "Stale")
	bson.EncodeBool(buf, zkNode.Stale)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Esempio n. 13
0
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeFloat64(buf, "Float64", myType.Float64)
	bson.EncodeString(buf, "String", myType.String)
	bson.EncodeBool(buf, "Bool", myType.Bool)
	bson.EncodeInt64(buf, "Int64", myType.Int64)
	bson.EncodeInt32(buf, "Int32", myType.Int32)
	bson.EncodeInt(buf, "Int", myType.Int)
	bson.EncodeUint64(buf, "Uint64", myType.Uint64)
	bson.EncodeUint32(buf, "Uint32", myType.Uint32)
	bson.EncodeUint(buf, "Uint", myType.Uint)
	bson.EncodeBinary(buf, "Bytes", myType.Bytes)
	bson.EncodeTime(buf, "Time", myType.Time)
	bson.EncodeInterface(buf, "Interface", myType.Interface)

	lenWriter.Close()
}
Esempio n. 14
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.EncodeBool(buf, "AsTransaction", queryList.AsTransaction)
	bson.EncodeInt64(buf, "TransactionId", queryList.TransactionId)

	lenWriter.Close()
}
Esempio n. 15
0
// 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()
}
Esempio n. 16
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()
}