Skip to content
ConsoleMonster
Class

GroupedStreamingTable<T, TState>

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

Streams contiguous groups with fixed sampled column widths and one aggregate summary at each group boundary. Keeps at most 200 sampled rows and the current aggregate, rather than buffering a group or the whole input. A repeated group key after another group starts a new group. Early disposal does not declare a group complete.

Inheritance

  • object
  • GroupedStreamingTable<T, TState>

Type Parameters

T
The input record.
TState
The caller-owned aggregate state; use bounded state to retain bounded memory.

Constructors

public GroupedStreamingTable<T, TState>(IEnumerable<TableColumn> columns, Func<T?, string> group, Func<T?, TableCell[]> row, Func<string, TState?> seed, Func<TState?, T?, TState?> aggregate, Func<string, TState?, long, IWidget?> summary) #

Creates a streaming table. The summary is invoked exactly once per fully read contiguous group.

Parameters

columns System.Collections.Generic.IEnumerable<ConsoleMonster.Widgets.TableColumn> required
Data columns, copied without modifying the caller's definitions.
group System.Func<T?, string> required
The plain text group key, compared ordinally.
row System.Func<T?, ConsoleMonster.Widgets.TableCell[]> required
Projects one record to cells in column order.
seed System.Func<string, TState?> required
Creates an aggregate when a group opens.
aggregate System.Func<TState?, T?, TState?> required
Updates the aggregate for one record.
summary System.Func<string, TState?, long, ConsoleMonster.Layout.IWidget?> required
Creates the closed group's summary using key, aggregate and row count; null omits it.

Methods

public IEnumerable<CellBuffer> RenderChunks(IEnumerable<T?> source, int width, RenderContext context) #

Lazily renders group headings, data rows and closure summaries. Disposing the result disposes the input. The first block reads at most GroupedStreamingTable<T1, T2>.SampleRows records; subsequent records stream one at a time. Columns hidden by the sampled layout are named once. Widths stay fixed for this enumeration.

Parameters

source System.Collections.Generic.IEnumerable<T?> required
The ordered record stream; it is enumerated once.
width int required
Output width in cells.
context ConsoleMonster.Canvas.RenderContext required
The existing render capabilities, theme and glyphs.

Returns

IEnumerable<CellBuffer> Append-only rendered blocks in input order.

Properties

public int SampleRows { get; set; } #

Rows sampled once for stable widths, from 1 to 200 (default 200). Does not grow with group size.

public PresentationOptions Presentation { get; set; } #

Culture, clock and time zone used by cell presenters.

public TableBorder Border { get; set; } #

Table border style for this stream (ordinary streams retain no border).

public bool RepeatHeaderPerGroup { get; set; } #

Whether each group repeats the column header; false prints one header before the first group.