txn

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CycleAnomalySpecs map[string]CycleAnomalySpecType

CycleAnomalySpecs defines anomaly specs

View Source
var CycleTypeNames map[string]struct{}

CycleTypeNames ...

View Source
var ProcessAnalysisTypes map[string]struct{}

ProcessAnalysisTypes saves types involving process edges

View Source
var RealtimeAnalysisTypes map[string]struct{}

RealtimeAnalysisTypes saves types involving realtime edges.

View Source
var UnknownAnomalyTypes map[string]struct{}

UnknownAnomalyTypes ...

Functions

func AdditionalGraphs

func AdditionalGraphs(opts Opts) []core.Analyzer

AdditionalGraphs determines what additional graphs we'll need to consider for this analysis.

func CycleCases

func CycleCases(graph core.DirectedGraph, pairExplainer core.DataExplainer, sccs []core.SCC) map[string][]core.Anomaly

CycleCases finds anomaly cases and group them by there name

func CycleCasesInScc

func CycleCasesInScc(graph core.DirectedGraph, filterGraph FilterGraphFn, explainer core.DataExplainer, scc core.SCC) []core.CycleExplainerResult

CycleCasesInScc searches a single SCC for cycle anomalies. TODO: add timeout logic.

func Cycles

func Cycles(analyzer core.Analyzer, history core.History, opts ...interface{}) core.CheckResult

Cycles takes an options map, including a collection of expected consistency models

:consistency-models, a set of additional :anomalies, an analyzer function,
and a history. Analyzes the history and yields the analysis, plus an anomaly
map like {:G1c [...]}.

func CyclesWithDraw

func CyclesWithDraw()

CyclesWithDraw means "cycles!" in clojure. TODO: This function contains some logic like draw, so I leave it unimplemented.

func FailedWrites

func FailedWrites(history core.History) map[string]map[core.MopValueType]*core.Op

FailedWrites is like IntermediateWrites, it returns map[key](map[aborted-value]abort-op).

func Gen

func Gen(mop []core.Mop) core.Op

Gen Takes a sequence of transactions and returns a sequence of invocation operations. Note: Currently we don't need :f.

func IntArrayHash

func IntArrayHash(array []int) uint32

IntArrayHash maps []int to uint32

func IntermediateWrites

func IntermediateWrites(history core.History) map[string]map[core.MopValueType]*core.Op

IntermediateWrites return a map likes map[key](map[old-version]overwrite-op). Note: This function is very very strange, please pay attention to it carefully.

Types

type CheckResult

type CheckResult struct {
	// valid? true | :unknown | false
	IsUnknown        bool           `json:"is_unknown"`
	Valid            bool           `json:"valid"`
	AnomalyTypes     []string       `json:"anomaly_types"`
	Anomalies        core.Anomalies `json:"anomalies"`
	ImpossibleModels []interface{}  `json:"impossible_models"`
	Not              []string       `json:"not"`
	AlsoNot          []string       `json:"also_not"`
}

CheckResult records the check result

func ResultMap

func ResultMap(opts Opts, anomalies core.Anomalies) CheckResult

ResultMap takes opts and processes anomalies

func (CheckResult) Error

func (c CheckResult) Error() string

type CycleAnomalySpecType

type CycleAnomalySpecType struct {
	// A set of relationships which must intersect with every edge in the cycle.
	Rels map[core.Rel]struct{}

	// A set of relationships which must intersect with the first edge in the cycle.
	FirstRel core.Rel
	// A set of relationships which must intersect with remaining edges.
	RestRels map[core.Rel]struct{}

	// A predicate over a cycle explanation. We use this to restrict cycles to e.g. *just* G2 instead of G-single.
	FilterEx FilterExType

	// A predicate over a cycle
	With core.CyclePredicate
}

CycleAnomalySpecType specifies different anomalies

type CycleExplainerWrapper

type CycleExplainerWrapper struct{}

CycleExplainerWrapper is a ICycleExplainer, it's also a wrapper for core.

func (CycleExplainerWrapper) ExplainCycle

func (c CycleExplainerWrapper) ExplainCycle(pairExplainer core.DataExplainer, circle core.Circle) core.CycleExplainerResult

ExplainCycle ...

func (CycleExplainerWrapper) RenderCycleExplanation

func (c CycleExplainerWrapper) RenderCycleExplanation(explainer core.DataExplainer, cr core.CycleExplainerResult) string

RenderCycleExplanation ...

type DistMode

type DistMode = int

DistMode contains uniform or exponential distribution

const (
	// Uniform means uniform distribution, every key has an equal probability of appearing.
	Uniform DistMode = iota
	// Exponential means that key i in the current key pool chosen.
	Exponential
)

type FilterExType

type FilterExType = func(cycleCase *core.CycleExplainerResult) bool

FilterExType is a predication on a cycle case

type FilterGraphFn

type FilterGraphFn = func(rels []core.Rel) *core.DirectedGraph

FilterGraphFn ...

func FilteredGraphs

func FilteredGraphs(graph core.DirectedGraph) FilterGraphFn

FilteredGraphs receives a graph and a collection of relations, return a new Graph filtered to just those relationships Note: currently it use fork here, we can considering remove it.

type KeyDist

type KeyDist struct {
	DistMode DistMode
}

KeyDist means the distribution of the keys. Defaults to :exponential.

type MopIterator

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

MopIterator records the state of the mop generator

func WrTxn

func WrTxn(opts WrTxnOpts) *MopIterator

WrTxn ...

func WrTxnWithDefaultOpts

func WrTxnWithDefaultOpts() *MopIterator

WrTxnWithDefaultOpts ...

func (*MopIterator) Next

func (mIter *MopIterator) Next() []core.Mop

Next iterates next element

If the operation is `read`, it will just return [:r key nil]
If the operation is `write`, it will just return [:w key value]

type OpMopIterator

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

OpMopIterator builds a op-mop iterator

func OpMops

func OpMops(history core.History) *OpMopIterator

OpMops return an iterator for history.

func (*OpMopIterator) HasNext

func (omi *OpMopIterator) HasNext() bool

HasNext returns whether the iterator has ended

func (*OpMopIterator) Next

func (omi *OpMopIterator) Next() (core.Op, core.Mop)

Next iterates next op-mop

type Opts

type Opts struct {
	// define what specific anomalies and consistency models to look for
	ConsistencyModels []core.ConsistencyModelName
	Anomalies         []string
	AdditionalGraphs  []core.Analyzer
}

Opts contains consistencyModels, Anomalies and AdditionalGraphs etc

type WrTxnOpts

type WrTxnOpts struct {
	KeyDist KeyDist
	// The base for an exponential distribution.
	// Defaults to 2, so the first key is twice as likely as the second,
	//  which is twice as likely as the third, etc.
	KeyDistBase     uint
	KeyCount        uint
	MinTxnLength    uint
	MaxTxnLength    uint
	MaxWritesPerKey uint
}

WrTxnOpts ...

func DefaultWrTxnOpts

func DefaultWrTxnOpts() WrTxnOpts

DefaultWrTxnOpts returns default opts

type WrTxnState

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

WrTxnState ...

Jump to

Keyboard shortcuts

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