iterator

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT, MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SeekThreshold = 1024 * 1024

Only enable seekLog when position range is more than SeekThreshold. The suggested value of SeekThreshold is the biggest log size.

View Source
const SlowLogQueryFileName = "tidb_slow_query.log"

Define the slow query file name

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator interface {
	// parse next log item
	Next() (item.Item, error)

	// close resource
	Close() error
}

type IteratorWithPeek

type IteratorWithPeek interface {
	Iterator

	// the next item Next() will return
	Peek() item.Item
}

func New

func New(fw *parser.FileWrapper, begin, end time.Time) (IteratorWithPeek, error)

Generate a new iterator from a specific file and a time range. The iterator should only return logs in the [begin, end] time range.

type LogIterator

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

LogIterator implements Iterator and IteratorWithPeek interface. It's used for reading logs from log files one by one by their time.

func (*LogIterator) Close

func (iter *LogIterator) Close() error

The Close method close all resources the iterator has.

func (*LogIterator) Next

func (iter *LogIterator) Next() (current item.Item, err error)

The Next method return next log and error (if any), and read disk for future logs. If any erros happened in Next(), the error will not be returned immediately, instead, the error will be deplayed to the next call of Next().

func (*LogIterator) Peek

func (iter *LogIterator) Peek() item.Item

The Peek method returns next log, but don't change any state.

func (*LogIterator) Seek

func (iter *LogIterator) Seek(point time.Time) error

Seek tries to find the first log entity whose time is after the param point, if not found, io.EOF will be returned.

params:

point: the start point of the logs

return:

if found, nil
if not found, io.EOF
otherwise, other error

Jump to

Keyboard shortcuts

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