本文整理汇总了Golang中github.com/senarukana/rationaldb/util/bytes2.ChunkedWriter类的典型用法代码示例。如果您正苦于以下问题:Golang ChunkedWriter类的具体用法?Golang ChunkedWriter怎么用?Golang ChunkedWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChunkedWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: EncodeStructContent
func EncodeStructContent(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:dongzerun,项目名称:RationalDb,代码行数:29,代码来源:marshal.go
示例2: EncodeString
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:dongzerun,项目名称:RationalDb,代码行数:7,代码来源:marshal.go
示例3: MarshalBson
func (ps *PrivateStruct) MarshalBson(buf *bytes2.ChunkedWriter) {
lenWriter := NewLenWriter(buf)
EncodeUint64(buf, "Type", ps.veryPrivate)
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:8,代码来源:bson_test.go
示例4: EncodeBool
func EncodeBool(buf *bytes2.ChunkedWriter, key string, val bool) {
EncodePrefix(buf, Boolean, key)
if val {
buf.WriteByte(1)
} else {
buf.WriteByte(0)
}
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:8,代码来源:marshal.go
示例5: encodeFieldsBson
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()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:bson.go
示例6: MarshalBson
func (bdq *BoundQuery) MarshalBson(buf *bytes2.ChunkedWriter) {
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Sql", bdq.Sql)
EncodeBindVariablesBson(buf, "BindVariables", bdq.BindVariables)
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:bson.go
示例7: encodeRowsBson
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()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:bson.go
示例8: MarshalBson
func (kr *KeyRange) MarshalBson(buf *bytes2.ChunkedWriter) {
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Start", string(kr.Start))
bson.EncodeString(buf, "End", string(kr.End))
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:key.go
示例9: MarshalBson
func (req *RequestBson) MarshalBson(buf *bytes2.ChunkedWriter) {
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "ServiceMethod", req.ServiceMethod)
bson.EncodeInt64(buf, "Seq", int64(req.Seq))
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:custom_codecs.go
示例10: EncodeBindVariablesBson
func EncodeBindVariablesBson(buf *bytes2.ChunkedWriter, key string, bindVars map[string]interface{}) {
bson.EncodePrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
for k, v := range bindVars {
bson.EncodeField(buf, k, v)
}
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:bson.go
示例11: EncodeSlice
func EncodeSlice(buf *bytes2.ChunkedWriter, key string, val reflect.Value) {
EncodePrefix(buf, Array, key)
lenWriter := NewLenWriter(buf)
for i := 0; i < val.Len(); i++ {
encodeField(buf, Itoa(i), val.Index(i))
}
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:9,代码来源:marshal.go
示例12: MarshalFieldBson
func MarshalFieldBson(field Field, key string, buf *bytes2.ChunkedWriter) {
bson.EncodePrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
bson.EncodeString(buf, "Name", field.Name)
bson.EncodeInt64(buf, "Type", field.Type)
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:10,代码来源:bson.go
示例13: EncodeResultsBson
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()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:10,代码来源:bson.go
示例14: EncodeQueriesBson
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()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:10,代码来源:bson.go
示例15: MarshalBson
func (qr *QueryResult) MarshalBson(buf *bytes2.ChunkedWriter) {
lenWriter := bson.NewLenWriter(buf)
encodeFieldsBson(qr.Fields, "Fields", buf)
bson.EncodeInt64(buf, "RowsAffected", int64(qr.RowsAffected))
bson.EncodeInt64(buf, "InsertId", int64(qr.InsertId))
encodeRowsBson(qr.Rows, "Rows", buf)
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:11,代码来源:bson.go
示例16: encodeRowBson
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()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:13,代码来源:bson.go
示例17: EncodeStringArray
func EncodeStringArray(buf *bytes2.ChunkedWriter, name string, values []string) {
if values == nil {
EncodePrefix(buf, Null, name)
} else {
EncodePrefix(buf, Array, name)
lenWriter := NewLenWriter(buf)
for i, val := range values {
EncodeString(buf, Itoa(i), val)
}
buf.WriteByte(0)
lenWriter.RecordLen()
}
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:13,代码来源:marshal_util.go
示例18: EncodeMapContent
// a map seems to lose the 'CanAddr' property. So if we want
// to use a custom marshaler with a struct pointer receiver, like:
// func (ps *PrivateStruct) MarshalBson(buf *bytes2.ChunkedWriter) {
// the map has to be using pointers, i.e:
// map[string]*PrivateStruct
// and not:
// map[string]PrivateStruct
// (see unit test)
func EncodeMapContent(buf *bytes2.ChunkedWriter, val reflect.Value) {
lenWriter := NewLenWriter(buf)
mt := val.Type()
if mt.Key() != reflect.TypeOf("") {
panic(NewBsonError("can't marshall maps with non-string key types"))
}
keys := val.MapKeys()
for _, k := range keys {
key := k.String()
encodeField(buf, key, val.MapIndex(k))
}
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:22,代码来源:marshal.go
示例19: MarshalBson
func (sc *SimpleContainer) MarshalBson(buf *bytes2.ChunkedWriter) {
lenWriter := NewLenWriter(buf)
EncodeField(buf, "_Val_", sc._Val_)
buf.WriteByte(0)
lenWriter.RecordLen()
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:6,代码来源:marshal.go
示例20: NewLenWriter
func NewLenWriter(buf *bytes2.ChunkedWriter) LenWriter {
off := buf.Len()
b := buf.Reserve(_WORD32)
return LenWriter{buf, off, b}
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:5,代码来源:marshal.go
注:本文中的github.com/senarukana/rationaldb/util/bytes2.ChunkedWriter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论