// Size tries to determine the length of r. If r is an io.Seeker, Size may seek
// to guess the length.
967083
func Size(r io.Reader) (size int64, ok bool) {
	switch rt := r.(type) {
	case *bytes.Buffer:
		return int64(rt.Len()), true
	case *bytes.Reader:
		return int64(rt.Len()), true
	case *strings.Reader:
		return int64(rt.Len()), true
	case io.Seeker:
		pos, err := rt.Seek(0, os.SEEK_CUR)
		if err != nil {
			return
		}
		end, err := rt.Seek(0, os.SEEK_END)
		if err != nil {
			return
		}
		size = end - pos
		pos1, err := rt.Seek(pos, os.SEEK_SET)
		if err != nil || pos1 != pos {
			msg := "failed to restore seek position"
			if err != nil {
				msg += ": " + err.Error()
			}
			panic(msg)
		}
		return size, true
	}
	return 0, false
}
397923
func (lru *LRUCache) Size() int64 {
	lru.mu.Lock()
	defer lru.mu.Unlock()
	return lru.size
}
1207703
func (ts *Store) Size(id string) (int64, error) {
	sz, err := fileutil.DirSize(ts.GetPath(id))
	if err != nil {
		return -1, errwrap.Wrap(errors.New("error calculating size"), err)
	}
	return sz, nil
}
1291471
func (r Rect) Size() LatLng {
	return LatLng{s1.Angle(r.Lat.Length()) * s1.Radian, s1.Angle(r.Lng.Length()) * s1.Radian}
}
868049
func (af AttrFormat) Size() int {
	total := 0
	for _, attr := range af {
		total += attr.Type.Size()
	}
	return total
}
437198
func (infos FieldInfos) Size() int {
	assert(len(infos.byNumber) == len(infos.byName))
	return len(infos.byNumber)
}
655343
func (s *SearchService) Size(size int) *SearchService {
	s.searchSource = s.searchSource.Size(size)
	return s
}
1355375
func (c *Corpus) Size() int {
	size := atomic.LoadInt64(&c.maxid)
	return int(size)
}
1349802
func (o Options) Size() int {
	if o.recorder != nil {
		return o.recorder.Size()
	}

	return o.size
}
1022861
func (c Command) Size() int {
	if c.Payload != nil {
		return c.Payload.Size() + 1
	}
	return 1
}
467119
func (u *utxoStore) Size() (sz int) {
	u.Lock()
	defer u.Unlock()
	for _, m := range u.c {
		sz += len(m)
	}
	return
}
353852
func (a *BucketSortAggregation) Size(size int) *BucketSortAggregation {
	a.size = size
	return a
}
933484
func (s *SearchSource) Size(size int) *SearchSource {
	s.size = size
	return s
}
753937
func (t *ImmutableTree) Size() int64 {
	if t.root == nil {
		return 0
	}
	return t.root.size
}
1365314
func (r *Request) Size() int64 {
	return int64(r.context.Request.Header.ContentLength())
}
860608
func (f *HttpFile) Size() int64 {
	DebugLog(f.Debug).Println("Size", f.len)
	return f.len
}
11610
func (rs Ranges) Size() uint64 {
	var sz uint64
	for i := range rs {
		sz += 1 + (rs[i].End - rs[i].Begin)
	}
	return sz
}