// ReadDataFrom reads a binary representation of the Hll data written
// by WriteDataTo() from io stream. It returns the number of bytes read
// and error.
// If serialized Hll configuration is different it returns error with expected params
9777
func (h *HyperLogLog) ReadDataFrom(stream io.Reader) (int, error) {
	var m uint64
	// read register number first
	err := binary.Read(stream, binary.LittleEndian, &m)
	if err != nil {
		return 0, err
	}
	// check if register number is appropriate
	// hll register number should be same with serialized hll
	if uint64(h.m) != m {
		return 0, fmt.Errorf("expected hll register number %d", m)
	}
	// set other values
	err = binary.Read(stream, binary.LittleEndian, &h.b)
	if err != nil {
		return 0, err
	}

	err = binary.Read(stream, binary.LittleEndian, &h.alpha)
	if err != nil {
		return 0, err
	}

	err = binary.Read(stream, binary.LittleEndian, h.registers)
	if err != nil {
		return 0, err
	}

	// count size of data in registers + m, b, alpha
	size := int(h.m)*binary.Size(uint8(0)) + binary.Size(uint64(0)) + binary.Size(uint32(0)) + binary.Size(float64(0))

	return size, err
}
847138
func (t *TablePropApplySetField) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropXM(r, &t.Fields, &t.Miss)
}
909927
func (c *Conn) ReadFrom(b []byte) (int, net.Addr, error) {
	return c.p.ReadFrom(b)
}
665482
func (ac *arrayContainer) readFrom(stream io.Reader) (int, error) {
	buf := uint16SliceAsByteSlice(ac.content)
	return io.ReadFull(stream, buf)
}
247452
func (p *Ports) ReadFrom(r io.Reader) (n int64, err error) {
	var nn int64

	for err == nil {
		var port Port
		nn, err = port.ReadFrom(r)
		n += nn

		if err == io.EOF {
			err = nil
			return
		}

		*p = append(*p, port)
	}

	return
}
643337
func (b *BitSet) ReadFrom(stream io.Reader) (int64, error) {
	var length uint64

	// Read length first
	err := binary.Read(stream, binaryOrder, &length)
	if err != nil {
		return 0, err
	}
	newset := New(uint(length))

	if uint64(newset.length) != length {
		return 0, errors.New("Unmarshalling error: type mismatch")
	}

	// Read remaining bytes as set
	err = binary.Read(stream, binaryOrder, newset.set)
	if err != nil {
		return 0, err
	}

	*b = *newset
	return int64(b.BinaryStorageSize()), nil
}
14626
func (q *QueueStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &q.Port, &q.Queue)
}
98289
func (h *Hello) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &h.Elements)
}
1218705
func (a *AggregateStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &a.Table, &defaultPad3,
		&a.OutPort, &a.OutGroup, &defaultPad4, &a.Cookie,
		&a.CookieMask, &a.Match)
}
1196525
func (s *String) ReadFrom(r io.Reader) (n int64, err error) {
	// unsigned short, can't use Short
	var length uint16
	err = binary.Read(r, binary.BigEndian, &length)
	if err != nil {
		return 0, err
	}
	n = int64(length)

	if length > 0 {
		// Read length bytes
		arr := make([]byte, length)

		var nn int
		nn, err = io.ReadFull(r, arr)
		if err != nil {
			return
		}
		n += int64(nn)

		s.Value = string(arr)
	}

	return
}
739801
func (s *String) ReadFrom(r Reader, l int) error {
	var ba ByteSlice
	if err := ba.ReadFrom(r, l); err != nil {
		return err
	}
	*s = String(ba)

	return nil
}
1372824
func (a *ActionSetNetworkTTL) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad4, &a.TTL, &defaultPad3)
}
528645
func (a *p2SHScript) ReadFrom(r io.Reader) (n int64, err error) {
	//read length
	var lenBytes [4]byte

	read, err := io.ReadFull(r, lenBytes[:])
	n += int64(read)
	if err != nil {
		return n, err
	}

	length := binary.LittleEndian.Uint32(lenBytes[:])

	script := make([]byte, length)

	read, err = io.ReadFull(r, script)
	n += int64(read)
	if err != nil {
		return n, err
	}

	*a = script

	return n, nil
}
186667
func (f *BloomFilter) ReadFrom(stream io.Reader) (int64, error) {
	var m, k uint64
	err := binary.Read(stream, binary.BigEndian, &m)
	if err != nil {
		return 0, err
	}
	err = binary.Read(stream, binary.BigEndian, &k)
	if err != nil {
		return 0, err
	}
	b := &bitset.BitSet{}
	numBytes, err := b.ReadFrom(stream)
	if err != nil {
		return 0, err
	}
	f.m = uint(m)
	f.k = uint(k)
	f.b = b
	return numBytes + int64(2*binary.Size(uint64(0))), nil
}
848706
func (e *Experimenter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &e.Experimenter, &e.ExpType)
}
265176
func (xm *XM) ReadFrom(r io.Reader) (n int64, err error) {
	return xm.readFrom(r, true)
}
403584
func (t *TablePropWildcards) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropXM(r, &t.Fields, nil)
}