// ToTableWriterRow generate data for table writer
189562
func (f FeedMeta) ToTableWriterRow() []string {
	y, _, _ := f.Year()
	fetched, latest := f.modifiedTimesToStrs()
	return []string{
		f.color(f.source()),
		f.color(y),
		f.StatusForStdout(),
		f.color(fetched),
		f.color(latest),
	}
}
515919
func (t ConnectionTable) WriteTo(w io.Writer) (n int64, err error) {
	if err = binary.Write(w, binary.LittleEndian, t.Row); err != nil {
		return
	}
	n += int64(binary.Size(t.Row))
	if err = binary.Write(w, binary.LittleEndian, t.Col); err != nil {
		return
	}
	n += int64(binary.Size(t.Col))
	for i := range t.Vec {
		if err = binary.Write(w, binary.LittleEndian, t.Vec[i]); err != nil {
			return n, err
		}
		n += int64(binary.Size(t.Vec[i]))
	}
	return
}
441607
func (idx IndexTable) WriteTo(w io.Writer) (n int64, err error) {
	if n, err = idx.Da.WriteTo(w); err != nil {
		return
	}
	keys := make([]int32, 0, len(idx.Dup))
	for k := range idx.Dup {
		keys = append(keys, k)
	}
	sort.Slice(keys, func(i, j int) bool {
		return keys[i] < keys[j]
	})
	sz := int64(len(keys))
	if err = binary.Write(w, binary.LittleEndian, sz); err != nil {
		return
	}
	n += int64(binary.Size(sz))
	for _, k := range keys {
		if err = binary.Write(w, binary.LittleEndian, k); err != nil {
			return
		}
		n += int64(binary.Size(k))
		v := idx.Dup[k]
		if err = binary.Write(w, binary.LittleEndian, v); err != nil {
			return
		}
		n += int64(binary.Size(v))
	}
	return
}
977360
func (m *postgresMigrator) insertRow(i int) string {
	return fmt.Sprintf("INSERT INTO %s (n) VALUES(%d)", MIGRATION_TABLE, i)
}
277023
func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex int, row []string) error {

	height := t.rowHeight[rowIndex]

	// Compute the index of the last column as the min number of
	// cells in the header and cells in the current row.
	// Note: math.Min seems to be for float only :(
	last := len(t.headers) - 1
	lastr := len(row) - 1
	if lastr < last {
		last = lastr
	}

	// Note how we always print into a line buffer before placing
	// the assembled line into the result. This allows us to trim
	// superfluous trailing whitespace from the line before making
	// it final.

	if height <= 1 {
		// Easy case, all cells in the row are single-line
		line := &bytes.Buffer{}

		for columnIndex := range row {
			// Truncate long row, ignore the additional fields.
			if columnIndex >= len(t.headers) {
				break
			}

			err := t.printCellValue(line, transformer, columnIndex, last, row[columnIndex])
			if err != nil {
				return err
			}
		}

		fmt.Fprintf(result, "%s\n", trim(string(line.Bytes())))
		return nil
	}

	// We have at least one multi-line cell in this row.
	// Treat it a bit like a mini-table.

	// Step I. Fill the mini-table. Note how it is stored
	//         column-major, not row-major.

	// [column][row]string
	sub := make([][]string, len(t.headers))
	for columnIndex := range row {
		// Truncate long row, ignore the additional fields.
		if columnIndex >= len(t.headers) {
			break
		}
		sub[columnIndex] = strings.Split(row[columnIndex], "\n")
		// (*) Extend the column to the full height.
		for len(sub[columnIndex]) < height {
			sub[columnIndex] = append(sub[columnIndex], "")
		}
	}

	// Step II. Iterate over the rows, then columns to
	//          collect the output. This assumes that all
	//          the rows in sub are the same height. See
	//          (*) above where that is made true.

	for rowIndex := range sub[0] {
		line := &bytes.Buffer{}

		for columnIndex := range sub {
			err := t.printCellValue(line, transformer, columnIndex, last, sub[columnIndex][rowIndex])
			if err != nil {
				return err
			}
		}

		fmt.Fprintf(result, "%s\n", trim(string(line.Bytes())))
	}
	return nil
}
1250133
func (t *TablePropNextTables) WriteTo(w io.Writer) (int64, error) {
	headerlen := tablePropLen + len(t.NextTables)
	header := tableProp{t.Type(), uint16(headerlen)}

	padding := makePad(headerlen)
	return encoding.WriteTo(w, header, t.NextTables, padding)
}
1360615
func (r *AccessLogRecord) WriteTo(w io.Writer) (int64, error) {
	bytesWritten, err := w.Write(r.getRecord())
	return int64(bytesWritten), err
}
675811
func NewWriter(writer io.Writer) *Table {
	t := &Table{
		out:           writer,
		rows:          [][]string{},
		lines:         [][][]string{},
		cs:            make(map[int]int),
		rs:            make(map[int]int),
		headers:       [][]string{},
		footers:       [][]string{},
		caption:       false,
		captionText:   "Table caption.",
		autoFmt:       true,
		autoWrap:      true,
		reflowText:    true,
		mW:            MAX_ROW_WIDTH,
		pCenter:       CENTER,
		pRow:          ROW,
		pColumn:       COLUMN,
		tColumn:       -1,
		tRow:          -1,
		hAlign:        ALIGN_DEFAULT,
		fAlign:        ALIGN_DEFAULT,
		align:         ALIGN_DEFAULT,
		newLine:       NEWLINE,
		rowLine:       false,
		hdrLine:       true,
		borders:       Border{Left: true, Right: true, Bottom: true, Top: true},
		colSize:       -1,
		headerParams:  []string{},
		columnsParams: []string{},
		footerParams:  []string{},
		columnsAlign:  []int{}}
	return t
}
817375
func (s *StableBloomFilter) WriteTo(stream io.Writer) (int64, error) {
	err := binary.Write(stream, binary.BigEndian, uint64(s.m))
	if err != nil {
		return 0, err
	}
	err = binary.Write(stream, binary.BigEndian, uint64(s.p))
	if err != nil {
		return 0, err
	}
	err = binary.Write(stream, binary.BigEndian, uint64(s.k))
	if err != nil {
		return 0, err
	}
	err = binary.Write(stream, binary.BigEndian, s.max)
	if err != nil {
		return 0, err
	}
	err = binary.Write(stream, binary.BigEndian, int64(len(s.indexBuffer)))
	if err != nil {
		return 0, err
	}
	for _, index := range s.indexBuffer {
		err = binary.Write(stream, binary.BigEndian, uint64(index))
		if err != nil {
			return 0, err
		}
	}
	n, err := s.cells.WriteTo(stream)
	if err != nil {
		return 0, err
	}
	return int64((3+len(s.indexBuffer))*binary.Size(uint64(0))) +
		int64(1*binary.Size(uint8(0))) + int64(1*binary.Size(int64(0))) + n, err
}
312243
func (t *tableCommon) WritableCols() []*table.Column {
	if len(t.writableColumns) > 0 {
		return t.writableColumns
	}
	writableColumns := make([]*table.Column, len(t.Columns))
	maxOffset := -1
	for _, col := range t.Columns {
		if col.State == model.StateDeleteOnly || col.State == model.StateDeleteReorganization {
			continue
		}
		writableColumns[col.Offset] = col
		if maxOffset < col.Offset {
			maxOffset = col.Offset
		}
	}
	return writableColumns[0 : maxOffset+1]
}
1159392
func WriteTable(w io.Writer, table Table, style TableStyler) {
	if style == nil {
		style = defaultStyle
	}
	rowCount, colCount := table.RowCount(), table.ColCount()
	if rowCount <= 0 || colCount <= 0 {
		return
	}
	widthArray := make([]int, colCount)
	for j := 0; j < colCount; j++ {
		maxWidth := 0
		for i := 0; i < rowCount; i++ {
			width := len(table.Get(i, j))
			if i == 0 || width > maxWidth {
				maxWidth = width
			}
		}
		widthArray[j] = maxWidth
	}
	cw := newColorWriter(w)
	rowBorder := rowBorderLine(widthArray)
	style.BorderRender(rowBorder, cw)
	for i := 0; i < rowCount; i++ {
		fmt.Fprint(cw, "\n")
		writeTableRow(cw, table, i, widthArray, style)
		fmt.Fprint(cw, "\n")
		style.BorderRender(rowBorder, cw)
	}
	fmt.Fprint(cw, "\n")
}
780499
func (pr *Properties) SetRow(row int, r []string) {
	for row >= len(pr.DataFrame) {
		pr.DataFrame = append(pr.DataFrame, []string{})
	}
	pr.DataFrame[row] = r
}
783764
func FormatTabular(writer io.Writer, value interface{}) error {
	payloads, valueConverted := value.([]FormattedPayload)
	if !valueConverted {
		return errors.Errorf("expected value of type %T, got %T", payloads, value)
	}

	// TODO(ericsnow) sort the rows first?

	tw := output.TabWriter(writer)

	// Write the header.
	fmt.Fprintln(tw, tabularSection)
	fmt.Fprintln(tw, tabularHeader)

	// Print each payload to its own row.
	for _, payload := range payloads {
		// tabularColumns must be kept in sync with these.
		fmt.Fprintf(tw, tabularRow+"\n",
			payload.Unit,
			payload.Machine,
			payload.Class,
			payload.Status,
			payload.Type,
			payload.ID,
			strings.Join(payload.Labels, " "),
		)
	}
	tw.Flush()

	return nil
}
457053
func (t *Tabulate) buildRow(elements []string, padded_widths []int, paddings []int, d Row) string {

	var buffer bytes.Buffer
	buffer.WriteString(d.begin)
	padFunc := t.getAlignFunc()
	// Print contents
	for i := 0; i < len(padded_widths); i++ {
		output := ""
		if len(elements) <= i || (len(elements) > i && elements[i] == " nil ") {
			output = padFunc(padded_widths[i], t.EmptyVar)
		} else if len(elements) > i {
			output = padFunc(padded_widths[i], elements[i])
		}
		buffer.WriteString(output)
		if i != len(padded_widths)-1 {
			buffer.WriteString(d.sep)
		}
	}

	buffer.WriteString(d.end)
	return buffer.String()
}
702544
func (t *TableStats) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, t.Table, pad3{},
		t.ActiveCount, t.LookupCount, t.MatchedCount)
}
1087317
func (*InsertsQueryBuilder) WriteRow(buffer *bytes.Buffer, row []sqltypes.Value) {
	// Example: (0, 10, 'a'), (1, 11, 'b')
	buffer.WriteByte('(')
	for i, value := range row {
		if i > 0 {
			buffer.WriteByte(',')
		}
		value.EncodeSQL(buffer)
	}
	buffer.WriteByte(')')
}
777595
func (t *Table) AddRow(data ...interface{}) *Table {
	t.mtx.Lock()
	defer t.mtx.Unlock()
	r := NewRow(data...)
	t.Rows = append(t.Rows, r)
	return t
}