lastseen

package module
v0.0.0-...-9303919 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: MIT Imports: 3 Imported by: 0

README

lastseen Circle CI GoDoc

Package lastseen implements a last-seen sketch in Go.

Refer to our blog post for an explanation of how it works: https://www.vividcortex.com/blog/2015/07/10/probabilistic-sampling-sketch/.

Contributing

We only accept pull requests for minor fixes or improvements. This includes:

  • Small bug fixes
  • Typos
  • Documentation or comments

Please open issues to discuss new features. Pull requests for new features will be rejected, so we recommend forking the repository and making changes in your fork for your use case.

License

MIT (see LICENSE)

Documentation

Overview

Package lastseen implements a last-seen sketch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sketch

type Sketch [numBuckets][]time.Time

Sketch is a last-seen sketch.

func NewSketch

func NewSketch(N int) Sketch

NewSketch returns a sketch that can hold N elements, offering ~1% false positives for lookups. N should be at most 45805.

func (Sketch) Capacity

func (sk Sketch) Capacity() int

Capacity returns the maximum number of distinct elements that can be held by the sketch with ~1% false positives

func (Sketch) CountDistinct

func (sk Sketch) CountDistinct(since time.Time) int

CountDistinct returns the minimum number of distinct elements seen since the given time.

func (Sketch) Lookup

func (sk Sketch) Lookup(key uint64) time.Time

Lookup returns the latest possible time that the key could have been updated in the sketch. The zero time is returned if the key has never been updated.

func (Sketch) LookupAndUpdate

func (sk Sketch) LookupAndUpdate(key uint64, now time.Time) time.Time

LookupAndUpdate returns the current timestamp for key and updates it.

func (Sketch) String

func (sk Sketch) String() string

String returns the string representation of the sketch.

func (Sketch) Update

func (sk Sketch) Update(key uint64, now time.Time) bool

Update updates the timestamps in the sketch to now. It returns true if the key was seen before.

Jump to

Keyboard shortcuts

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