sorters

package
v0.20.1-0...-33f8d6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTopNRows

func GetTopNRows(ctx *sql.Context, iter sql.RowIter, sortConditions sql.SortConditions, n int64) ([]sql.Row, int64, error)

GetTopNRows uses a Top-N Heap Sort to find the top (min) N rows in a RowIter. It inserts each row of the iter into the max-heap, popping the max row if the size of the heap exceeds N such that the heap only contains the N min rows. At the end, it pops the contents of the heap and returns them in min-first order.

Types

type RowSorter

type RowSorter struct {
	// contains filtered or unexported fields
}

RowSorter is a sorter implementation for Row slices using SortFields for the comparison

func NewRowSorter

func NewRowSorter(ctx *sql.Context, sortConditions sql.SortConditions) *RowSorter

func NewRowSorterWithRows

func NewRowSorterWithRows(ctx *sql.Context, sortConditions sql.SortConditions, rows []sql.Row) *RowSorter

func (*RowSorter) CompareRows

func (s *RowSorter) CompareRows(a, b sql.Row) int

CompareRows compares rows a and b based on s.SortFields

func (*RowSorter) GetError

func (s *RowSorter) GetError() error

func (*RowSorter) IsLesserRow

func (s *RowSorter) IsLesserRow(a, b sql.Row) bool

IsLesserRow determines if sql.Row `a` is less than sql.Row `b` based off s.SortFields

func (*RowSorter) Len

func (s *RowSorter) Len() int

Len implements sort.Interface

func (*RowSorter) Less

func (s *RowSorter) Less(i, j int) bool

Less implements sort.Interface interface.

func (*RowSorter) Swap

func (s *RowSorter) Swap(i, j int)

Swap implements sort.Interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL