Documentation ¶
Index ¶
- type OPIC
- func (o *OPIC) Dirty() bool
- func (o *OPIC) Distribute(source string, out []string, t time.Time) float64
- func (o *OPIC) EnsureBalance(n float64)
- func (o *OPIC) Estimate(s string, interval time.Duration, t time.Time) float64
- func (o *OPIC) EstimateN(v uint64, interval time.Duration, t time.Time) float64
- func (o *OPIC) EstimateNV(v []uint64, interval time.Duration, t time.Time) []float64
- func (o *OPIC) EstimateV(v []string, interval time.Duration, t time.Time) []float64
- func (o *OPIC) Finalise(in []string)
- func (o *OPIC) Get(s string) (float64, float64, time.Time)
- func (o *OPIC) GetN(v uint64) (float64, float64, time.Time)
- func (o *OPIC) Initialise(cash float64, in []string)
- func (o *OPIC) InitialiseN(cash float64, in []uint64)
- func (o *OPIC) Sums() (float64, float64)
- func (o *OPIC) Virtual() (float64, float64)
- type Persistent
- type PersistentLoadOptions
- type Serialisable
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 (*OPIC) Dirty ¶
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 ¶
Distribute distributes the cash from the input to the outputs, and marks the input as having been fetched.
func (*OPIC) EnsureBalance ¶
EnsureBalance "tops up" the cash in the system, allowing the user to correct for slight inaccuracies in floating point math.
func (*OPIC) EstimateNV ¶
EstimateNV estimates the total for a list of entries, referenced by numeric hash.
func (*OPIC) Initialise ¶
Initialise sets the total cash for the system, and distributes it evenly amongst a collection of URLs.
func (*OPIC) InitialiseN ¶
InitialiseN sets the total cash for the system, and distributes it evenly amongst a collection of URLs referenced by numeric hash.
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 ¶
func (p *Persistent) Load(o *PersistentLoadOptions) error
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