opic

package module
v0.0.0-...-2420f5d Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2016 License: BSD-3-Clause Imports: 9 Imported by: 1

README

opic

GoDoc

Overview

OPIC stands for "On-Line Page Importance Computation". This package implements the adaptive form of the algorithm, and atop that, some functions for approximating the static form.

License

3-clause BSD. A copy is included with the source.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OPIC

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

OPIC holds all the state for running the Adaptive OPIC algorithm.

func New

func New() *OPIC

New constructs a new OPIC object.

func (*OPIC) Dirty

func (o *OPIC) Dirty() bool

Dirty returns true if there have been any changes since the last time the OPIC instance was loaded or saved. It's intended that this be used by the persistency layer to decide what to do.

func (*OPIC) Distribute

func (o *OPIC) Distribute(source string, out []string, t time.Time) float64

Distribute distributes the cash from the input to the outputs, and marks the input as having been fetched.

func (*OPIC) EnsureBalance

func (o *OPIC) EnsureBalance(n float64)

EnsureBalance "tops up" the cash in the system, allowing the user to correct for slight inaccuracies in floating point math.

func (*OPIC) Estimate

func (o *OPIC) Estimate(s string, interval time.Duration, t time.Time) float64

Estimate estimates the total for an entry.

func (*OPIC) EstimateN

func (o *OPIC) EstimateN(v uint64, interval time.Duration, t time.Time) float64

EstimateN estimates the total for an entry, referenced by numeric hash.

func (*OPIC) EstimateNV

func (o *OPIC) EstimateNV(v []uint64, interval time.Duration, t time.Time) []float64

EstimateNV estimates the total for a list of entries, referenced by numeric hash.

func (*OPIC) EstimateV

func (o *OPIC) EstimateV(v []string, interval time.Duration, t time.Time) []float64

EstimateV estimates the totals for a list of entries.

func (*OPIC) Finalise

func (o *OPIC) Finalise(in []string)

Finalise moves all the current values into the history for the inputs.

func (*OPIC) Get

func (o *OPIC) Get(s string) (float64, float64, time.Time)

Get gets the details for an entry.

func (*OPIC) GetN

func (o *OPIC) GetN(v uint64) (float64, float64, time.Time)

GetN gets the details for an entry, referenced by numeric hash.

func (*OPIC) Initialise

func (o *OPIC) Initialise(cash float64, in []string)

Initialise sets the total cash for the system, and distributes it evenly amongst a collection of URLs.

func (*OPIC) InitialiseN

func (o *OPIC) InitialiseN(cash float64, in []uint64)

InitialiseN sets the total cash for the system, and distributes it evenly amongst a collection of URLs referenced by numeric hash.

func (*OPIC) Sums

func (o *OPIC) Sums() (float64, float64)

Sums returns the total cash in the system. Ideally, these values would be the same. Unfortunately floating point math is a tiny bit inaccurate, so these diverge over time. See also EnsureBalance.

func (*OPIC) Virtual

func (o *OPIC) Virtual() (float64, float64)

Virtual gets the details for the "virtual" entry.

type Persistent

type Persistent struct {
	*Serialisable
	// contains filtered or unexported fields
}

Persistent extends OPIC with a disk-based persistency mechanism.

func NewPersistent

func NewPersistent(filename string) *Persistent

NewPersistent creates a new Persistent OPIC instance backed by a particular file.

func (*Persistent) Load

Load does what it sounds like. It loads the OPIC state from the file associated with this instance.

func (*Persistent) Save

func (p *Persistent) Save() error

Save does what it sounds like. It saves the OPIC state to the file associated with this instance.

type PersistentLoadOptions

type PersistentLoadOptions struct {
	IgnoreMissing bool
}

type Serialisable

type Serialisable struct {
	*OPIC
}

Serialisable extends OPIC with methods to serialise and deserialise a binary format representing the dataset.

func (*Serialisable) MarshalBinary

func (s *Serialisable) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*Serialisable) ReadFrom

func (s *Serialisable) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom

func (*Serialisable) UnmarshalBinary

func (s *Serialisable) UnmarshalBinary(d []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

func (*Serialisable) WriteTo

func (s *Serialisable) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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