当前位置: 首页>>代码示例>>Golang>>正文


Golang bytes2.ChunkedWriter类代码示例

本文整理汇总了Golang中github.com/youtube/vitess/go/bytes2.ChunkedWriter的典型用法代码示例。如果您正苦于以下问题:Golang ChunkedWriter类的具体用法?Golang ChunkedWriter怎么用?Golang ChunkedWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ChunkedWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: MarshalBson

func (qrl *QueryResultList) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)
	EncodeResultsBson(qrl.List, "List", buf)
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rudyLi,项目名称:vitess,代码行数:7,代码来源:bson.go

示例2: EncodeStruct

func EncodeStruct(buf *bytes2.ChunkedWriter, val reflect.Value) {
	// check the Marshaler interface on T
	if marshaler, ok := val.Interface().(Marshaler); ok {
		marshaler.MarshalBson(buf)
		return
	}
	// check the Marshaler interface on *T
	if val.CanAddr() {
		if marshaler, ok := val.Addr().Interface().(Marshaler); ok {
			marshaler.MarshalBson(buf)
			return
		}
	}

	lenWriter := NewLenWriter(buf)
	t := val.Type()
	for i := 0; i < t.NumField(); i++ {
		key := t.Field(i).Name

		// NOTE(szopa): Ignore private fields (copied from
		// encoding/json). Yes, it feels like a hack.
		if t.Field(i).PkgPath != "" {
			continue
		}
		encodeField(buf, key, val.Field(i))
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:29,代码来源:marshal.go

示例3: EncodeString

// EncodeString encodes a string.
func EncodeString(buf *bytes2.ChunkedWriter, key string, val string) {
	// Encode strings as binary; go strings are not necessarily unicode
	EncodePrefix(buf, Binary, key)
	putUint32(buf, uint32(len(val)))
	buf.WriteByte(0)
	buf.WriteString(val)
}
开发者ID:kingpro,项目名称:vitess,代码行数:8,代码来源:marshal.go

示例4: EncodeBool

func EncodeBool(buf *bytes2.ChunkedWriter, val bool) {
	if val {
		buf.WriteByte(1)
	} else {
		buf.WriteByte(0)
	}
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:7,代码来源:marshal.go

示例5: MarshalBson

func (blt *BinlogTransaction) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)
	MarshalStatementsBson(buf, "Statements", blt.Statements)
	bson.EncodeInt64(buf, "GroupId", blt.GroupId)
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rjammala,项目名称:vitess,代码行数:7,代码来源:binlog_transaction.go

示例6: encodeBindVariablesBson

func (query *Query) encodeBindVariablesBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)
	for k, v := range query.BindVariables {
		bson.EncodeField(buf, k, v)
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:8,代码来源:bson.go

示例7: MarshalBson

func (ps *PrivateStruct) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := NewLenWriter(buf)

	EncodeUint64(buf, "Type", ps.veryPrivate)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:qinbo,项目名称:vitess,代码行数:8,代码来源:bson_test.go

示例8: MarshalBson

func (blt *BinlogTransaction) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)
	MarshalStatementsBson(buf, "Statements", blt.Statements)
	bson.EncodeInt64(buf, "GroupId", blt.GroupId)
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rudyLi,项目名称:vitess,代码行数:8,代码来源:binlog_transaction.go

示例9: EncodeSlice

func EncodeSlice(buf *bytes2.ChunkedWriter, val reflect.Value) {
	lenWriter := NewLenWriter(buf)
	for i := 0; i < val.Len(); i++ {
		encodeField(buf, Itoa(i), val.Index(i))
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:8,代码来源:marshal.go

示例10: MarshalBson

func (zkPathV *ZkPathV) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeStringArray(buf, "Paths", zkPathV.Paths)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:8,代码来源:zkocc_bson.go

示例11: MarshalBson

func (zkPath *ZkPath) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "Path", zkPath.Path)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rjammala,项目名称:vitess,代码行数:8,代码来源:zkocc_bson.go

示例12: MarshalBson

func (kp *KeyspacePartition) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)

	EncodeSrvShardArray(buf, "Shards", kp.Shards)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rjammala,项目名称:vitess,代码行数:8,代码来源:srvshard.go

示例13: EncodeBool

// EncodeBool encodes a bool.
func EncodeBool(buf *bytes2.ChunkedWriter, key string, val bool) {
	EncodePrefix(buf, Boolean, key)
	if val {
		buf.WriteByte(1)
	} else {
		buf.WriteByte(0)
	}
}
开发者ID:kingpro,项目名称:vitess,代码行数:9,代码来源:marshal.go

示例14: MarshalBson

func (ps *PrivateStruct) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	EncodeOptionalPrefix(buf, Object, key)
	lenWriter := NewLenWriter(buf)

	EncodeUint64(buf, "Type", ps.veryPrivate)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rudyLi,项目名称:vitess,代码行数:9,代码来源:bson_test.go

示例15: MarshalPKRowBson

func MarshalPKRowBson(buf *bytes2.ChunkedWriter, key string, pkRow []interface{}) {
	bson.EncodePrefix(buf, bson.Array, key)
	lenWriter := bson.NewLenWriter(buf)
	for i, v := range pkRow {
		bson.EncodeField(buf, bson.Itoa(i), v)
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
开发者ID:rjammala,项目名称:vitess,代码行数:9,代码来源:stream_event.go


注:本文中的github.com/youtube/vitess/go/bytes2.ChunkedWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。