// The result surface: Rows, an iterator of named-column Row values. The// executor materializes the result set and Rows streams it from the buffer// (same contract as the Rust engine's lazy Rows).
package gqlimport ()// Row is one result row: named columns mapped to values. The column slice// is shared across every row of a result.typeRowstruct { columns []string values []value.Value}// Get returns the value of column name; ok is false when absent.func ( Row) ( string) (value.Value, bool) {for , := range .columns {if == {return .values[], true } }returnvalue.Value{}, false}// GetAt returns the value at output position i; ok is false out of range.func ( Row) ( int) (value.Value, bool) {if < 0 || >= len(.values) {returnvalue.Value{}, false }return .values[], true}// Values is the row's values in output-column order.func ( Row) () []value.Value { return .values }// Columns is the output column names, in order.func ( Row) () []string { return .columns }// Rows iterates a query's result rows.typeRowsstruct { columns []string rows [][]value.Value i int}// newRows wraps the executor's output buffer.func newRows( []string, [][]value.Value) *Rows {return &Rows{columns: , rows: }}// Columns is the output column names, in order.func ( *Rows) () []string { return .columns }// Next pulls the next row; ok is false when the result is exhausted.func ( *Rows) () (Row, bool) {if .i >= len(.rows) {returnRow{}, false } := Row{columns: .columns, values: .rows[.i]} .i++return , true}// NextBatch pulls up to n rows (fewer if the result is exhausted).func ( *Rows) ( int) []Row { := make([]Row, 0, )forrange { , := .Next()if ! {break } = append(, ) }return}// All iterates the remaining rows (range-over-func).func ( *Rows) () iter.Seq[Row] {returnfunc( func(Row) bool) {for { , := .Next()if ! || !() {return } } }}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.