Ejemplo n.º 1
0
func (u UpdateReq) IWrite(w *marshal.Writer) {
	w.Uint32(u.Space)
	var flags uint32
	if u.Return {
		flags = 1
	}
	w.Uint32(flags)
	WriteTuple(w, u.Key)
	w.Write(u.Ops)
}
Ejemplo n.º 2
0
func (o Op) IWrite(w *marshal.Writer) {
	w.Write(o.Field)
	if o.Op <= 7 {
		w.Write(o.Op)
	} else {
		w.Write(opmap[o.Op])
	}
	switch v := o.Val.(type) {
	case uint32:
		w.Int8(4)
		w.Uint32(v)
	case uint64:
		w.Int8(8)
		w.Uint64(v)
	case int32:
		w.Int8(4)
		w.Int32(v)
	case int64:
		w.Int8(8)
		w.Int64(v)
	case []byte:
		w.Intvar(len(v))
		w.Bytes(v)
	case string:
		w.Intvar(len(v))
		w.String(v)
	default:
		val := reflect.ValueOf(v)
		wr := marshal.WriterFor(val.Type())
		wr.WithSize(w, val, (*marshal.Writer).Intvar)
	}
}