// LazyCSVReader returns a lazy CSV reader, with LazyQuotes and TrimLeadingSpace.
179839
func LazyCSVReader(in io.Reader) CSVReader {
	csvReader := csv.NewReader(in)
	csvReader.LazyQuotes = true
	csvReader.TrimLeadingSpace = true
	return csvReader
}
833746
func WithIoReader(io io.ReadCloser) Reader {
	csvReader := csv.NewReader(io)
	csvReader.FieldsPerRecord = -1
	return WithCsvReader(csvReader, io)
}
887334
func (q *Queue) lazyGrow() {
	if q.full() {
		q.resize(len(q.rep) * 2)
	}
}
600667
func SelectOrder(i int, slice []int) int {
	rand.Seed(time.Now().Unix())
	cslice := make([]int, len(slice)) // copy
	copy(cslice, slice[:])
	return selectOrder(i, cslice)
}
202280
func makePartReader(
	ctr ContentTypedReader,
	first bool,
	boundary string) (r io.Reader) {
	// Set up a buffer containing the boundary.
	var b bytes.Buffer
	if first {
		fmt.Fprintf(&b, "--%s\r\n", boundary)
	} else {
		fmt.Fprintf(&b, "\r\n--%s\r\n", boundary)
	}

	fmt.Fprintf(&b, "Content-Type: %s\r\n", ctr.ContentType)
	fmt.Fprintf(&b, "\r\n")

	// Read the boundary followed by the content.
	r = io.MultiReader(&b, ctr.Reader)

	return
}
1170168
func (g *GcsFS) NewReader(o string) (io.ReadCloser, error) {
	return g.NewReaderWithContext(context.Background(), o)
}
1078421
func lazyOR(x1, x2 *Bitmap) *Bitmap {
	answer := NewBitmap()
	pos1 := 0
	pos2 := 0
	length1 := x1.highlowcontainer.size()
	length2 := x2.highlowcontainer.size()
main:
	for (pos1 < length1) && (pos2 < length2) {
		s1 := x1.highlowcontainer.getKeyAtIndex(pos1)
		s2 := x2.highlowcontainer.getKeyAtIndex(pos2)

		for {
			if s1 < s2 {
				answer.highlowcontainer.appendCopy(x1.highlowcontainer, pos1)
				pos1++
				if pos1 == length1 {
					break main
				}
				s1 = x1.highlowcontainer.getKeyAtIndex(pos1)
			} else if s1 > s2 {
				answer.highlowcontainer.appendCopy(x2.highlowcontainer, pos2)
				pos2++
				if pos2 == length2 {
					break main
				}
				s2 = x2.highlowcontainer.getKeyAtIndex(pos2)
			} else {
				c1 := x1.highlowcontainer.getContainerAtIndex(pos1)
				switch t := c1.(type) {
				case *arrayContainer:
					c1 = t.toBitmapContainer()
				case *runContainer16:
					if !t.isFull() {
						c1 = t.toBitmapContainer()
					}
				}

				answer.highlowcontainer.appendContainer(s1, c1.lazyOR(x2.highlowcontainer.getContainerAtIndex(pos2)), false)
				pos1++
				pos2++
				if (pos1 == length1) || (pos2 == length2) {
					break main
				}
				s1 = x1.highlowcontainer.getKeyAtIndex(pos1)
				s2 = x2.highlowcontainer.getKeyAtIndex(pos2)
			}
		}
	}
	if pos1 == length1 {
		answer.highlowcontainer.appendCopyMany(x2.highlowcontainer, pos2, length2)
	} else if pos2 == length2 {
		answer.highlowcontainer.appendCopyMany(x1.highlowcontainer, pos1, length1)
	}
	return answer
}
91547
func (s *GetCSVHeaderOutput) SetCSVHeader(v []*string) *GetCSVHeaderOutput {
	s.CSVHeader = v
	return s
}
67846
func compactionIterator(tc *tableCache, icmp db.Comparer, c *compaction) (cIter db.Iterator, retErr error) {
	iters := make([]db.Iterator, 0, len(c.inputs[0])+1)
	defer func() {
		if retErr != nil {
			for _, iter := range iters {
				if iter != nil {
					iter.Close()
				}
			}
		}
	}()

	if c.level != 0 {
		iter, err := newConcatenatingIterator(tc, c.inputs[0])
		if err != nil {
			return nil, err
		}
		iters = append(iters, iter)
	} else {
		for _, f := range c.inputs[0] {
			iter, err := tc.find(f.fileNum, nil)
			if err != nil {
				return nil, fmt.Errorf("leveldb: could not open table %d: %v", f.fileNum, err)
			}
			iters = append(iters, iter)
		}
	}

	iter, err := newConcatenatingIterator(tc, c.inputs[1])
	if err != nil {
		return nil, err
	}
	iters = append(iters, iter)
	return db.NewMergingIterator(icmp, iters...), nil
}
336615
func NewEvaluator(ce []ConsumedElement) (Evaluator, error) {
	e, tailCEs, err := internalNewEvaluator(ce)
	if err != nil {
		return nil, err
	}
	if len(tailCEs) > 1 || (len(tailCEs) == 1 && tailCEs[0].Token().Type != lexer.ItemRPar) {
		return nil, fmt.Errorf("failed to consume all token; left over %v", tailCEs)
	}
	return e, nil
}
509539
func NewPluginConfigReaderFromReader(reader PluginConfigReaderWithError) PluginConfigReader {
	errors := tgo.NewErrorStack()
	errors.SetFormat(tgo.ErrorStackFormatCSV)
	return PluginConfigReader{
		WithError: reader,
		Errors:    &errors,
	}
}
481008
func LazyChain(v interface{}) Builder {
	isNotNil(v, "LazyChain")

	valueType := reflect.TypeOf(v)
	if isValidBuilderEntry(valueType) ||
		(valueType.Kind() == reflect.Ptr && isValidBuilderEntry(valueType.Elem())) {
		return &lazyBuilder{func() interface{} { return v }}
	}

	panic(fmt.Sprintf("Type %s is not supported by LazyChain", valueType.String()))

}
784355
func CSVConsumer() Consumer {
	return ConsumerFunc(func(reader io.Reader, data interface{}) error {
		if reader == nil {
			return errors.New("CSVConsumer requires a reader")
		}

		csvReader := csv.NewReader(reader)
		writer, ok := data.(io.Writer)
		if !ok {
			return errors.New("data type must be io.Writer")
		}
		csvWriter := csv.NewWriter(writer)
		records, err := csvReader.ReadAll()
		if err != nil {
			return err
		}
		for _, r := range records {
			if err := csvWriter.Write(r); err != nil {
				return err
			}
		}
		csvWriter.Flush()
		return nil
	})
}
1239619
func NewNormalizedCSVEntryRecorder(events, props *csv.Writer) EntryRecorder {
	return nCSVRecorder{
		events: events,
		props:  props,
	}
}
972798
func (cr ChainReader) RemainingErr() (int64, error) {
	result := int64(0)
	for _, source := range cr {
		if source == nil {
			continue
		}
		r, ok := source.(interface {
			Len() int
		})
		if !ok {
			return 0, errors.New("chainreader: can only calculate Remaining for instances implementing Len()")
		}
		result += int64(r.Len())
	}
	return result, nil
}
14755
func NewCSVDecoder(rd io.Reader) Decoder {
	dec := csv.NewReader(rd)
	dec.FieldsPerRecord = 9
	dec.TrimLeadingSpace = true

	return func(r *Result) error {
		rec, err := dec.Read()
		if err != nil {
			return err
		}

		ts, err := strconv.ParseInt(rec[0], 10, 64)
		if err != nil {
			return err
		}
		r.Timestamp = time.Unix(0, ts)

		code, err := strconv.ParseUint(rec[1], 10, 16)
		if err != nil {
			return err
		}
		r.Code = uint16(code)

		latency, err := strconv.ParseInt(rec[2], 10, 64)
		if err != nil {
			return err
		}
		r.Latency = time.Duration(latency)

		if r.BytesOut, err = strconv.ParseUint(rec[3], 10, 64); err != nil {
			return err
		}

		if r.BytesIn, err = strconv.ParseUint(rec[4], 10, 64); err != nil {
			return err
		}

		r.Error = rec[5]
		r.Body, err = base64.StdEncoding.DecodeString(rec[6])

		r.Attack = rec[7]
		if r.Seq, err = strconv.ParseUint(rec[8], 10, 64); err != nil {
			return err
		}

		return err
	}
}
554482
func ParseCSVGetAttributesFromReader(r io.ReadSeeker, hasHeaders bool) []Attribute {
	attrs := ParseCSVSniffAttributeTypesFromReader(r, hasHeaders)
	names := ParseCSVSniffAttributeNamesFromReader(r, hasHeaders)
	for i, attr := range attrs {
		attr.SetName(names[i])
	}
	return attrs
}