func (dm *clusterMutation) Unserialize(reader typedio.Reader) { dm.version, _ = reader.ReadInt64() nbNodes, _ := reader.ReadUint16() dm.nodes = make([]*cluster.Node, nbNodes) var i uint16 for i = 0; i < nbNodes; i++ { node := cluster.NewEmptyNode() node.Unserialize(reader) dm.nodes[i] = node } }
func (e *segmentEntry) read(reader typedio.Reader) (err os.Error) { e.position, err = reader.ReadUint64() // position if err != nil { return err } tokenInt, err := reader.ReadUint16() // token if err != nil { return err } e.token = Token(tokenInt) e.mutsize, err = reader.ReadUint32() // size of mutation if err != nil { return err } e.mutation, err = mutationUnserialize(reader) // mutation if err != nil { return err } e.mutation.segEntry = e e.mutation.token = e.token e.mutation.seg = e.segment return }
func (cl *CommitLog) readOne(reader typedio.Reader) (mutInfo mutationInfo, size int64) { // read mutation id id, err := reader.ReadUint8() if err != nil { log.Fatal("CommitLog: Couldn't read mutation from commit log: %s", err) } // get the right mutation for the read id mutInfo, found := cl.mutations[id] if !found { log.Fatal("CommitLog: Cannot find mutation id %d!", id) } // read the mutation mutInfo.mutation.Unserialize(reader) // read size of the mutation record size, err = reader.ReadInt64() if err != nil && err != os.EOF { log.Fatal("CommitLog: Couldn't read size of mutation from commit log: %s", err) } return mutInfo, size }
func (n *Node) Unserialize(reader typedio.Reader) (err os.Error) { n.Id, err = reader.ReadUint16() // id if err != nil { return err } n.Status, err = reader.ReadUint8() // status if err != nil { return err } strAddr, err := reader.ReadString() // address if err != nil { return err } n.Address = net.ParseIP(strAddr) n.TcpPort, err = reader.ReadUint16() // tcp port if err != nil { return err } n.UdpPort, err = reader.ReadUint16() // udp port if err != nil { return err } nbRings, err := reader.ReadUint8() // nb rings if err != nil { return err } n.Rings = make([]NodeRing, nbRings) var i uint8 for i = 0; i < nbRings; i++ { // each ring nodeRing := NodeRing{} nodeRing.Ring, err = reader.ReadUint8() if err != nil { return err } nodeRing.Token, err = reader.ReadString() if err != nil { return err } } return nil }
func mutationUnserialize(reader typedio.Reader) (mut *mutation, err os.Error) { mut = &mutation{} mut.typ, err = reader.ReadUint16() // type if err != nil { return mut, err } switch mut.typ { case mut_create_vs: case mut_commit_vs: case mut_rollback_vs: mut.vs, err = reader.ReadUint32() // viewstate if err != nil { return mut, err } case mut_obj_op: opid, err := reader.ReadUint16() // operation id if err != nil { return mut, err } mut.op = id2operation(opid).(mutationOperation) var bytes []byte var bytecount uint32 bytecount, err = reader.ReadUint32() // operation size if err != nil { return mut, err } bytes = make([]byte, int(bytecount)) _, err = reader.Read(bytes) // operation if err != nil { return mut, err } err = proto.Unmarshal(bytes, mut.op) if err != nil { return mut, err } bytes = make([]byte, 1) _, err = reader.Read(bytes) // flags if err != nil { return mut, err } mut.flags = bytes[0] mut.lastPos, err = reader.ReadUint64() // object last position if err != nil { return mut, err } default: return nil, os.NewError(fmt.Sprintf("Unknown mutation type to unserialize: %d", mut.typ)) } return mut, err }
func (m *Int64Mutation) Unserialize(reader typedio.Reader) { m.val, _ = reader.ReadInt64() }