cockroach: github.com/cockroachdb/cockroach/pkg/sql/opt/constraint Index | Files

package constraint

import "github.com/cockroachdb/cockroach/pkg/sql/opt/constraint"

Index

Package Files

columns.go constraint.go constraint_set.go key.go key_extension.go span.go spans.go testutils.go

Variables

var Contradiction = &Set{contradiction: true}

Contradiction is a special constraint set which indicates there are no possible values for the expression; it will always yield the empty result set.

var EmptyKey = Key{}

EmptyKey has zero values. If it's a start key, then it sorts before all other keys. If it's an end key, then it sorts after all other keys.

var Unconstrained = &Set{}

Unconstrained is an empty constraint set which does not impose any constraints on any columns.

var UnconstrainedSpan = Span{}

UnconstrainedSpan is the span without any boundaries.

type Columns Uses

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

Columns identifies the columns which correspond to the values in a Key (and consequently the columns of a Span or Constraint).

The columns have directions; a descending column inverts the order of the values on that column (in other words, inverts the result of any Datum comparisons on that column).

func (*Columns) ColSet Uses

func (c *Columns) ColSet() opt.ColSet

ColSet returns the columns as a ColSet.

func (*Columns) Count Uses

func (c *Columns) Count() int

Count returns the number of constrained columns (always at least one).

func (*Columns) Equals Uses

func (c *Columns) Equals(other *Columns) bool

Equals returns true if the two lists of columns are identical.

func (*Columns) Get Uses

func (c *Columns) Get(nth int) opt.OrderingColumn

Get returns the nth column and direction. Together with the Count method, Get allows iteration over the list of constrained columns (since there is no method to return a slice of columns).

func (*Columns) Init Uses

func (c *Columns) Init(cols []opt.OrderingColumn)

Init initializes a Columns structure.

func (*Columns) InitSingle Uses

func (c *Columns) InitSingle(col opt.OrderingColumn)

InitSingle is a more efficient version of Init for the common case of a single column.

func (*Columns) IsStrictSuffixOf Uses

func (c *Columns) IsStrictSuffixOf(other *Columns) bool

IsStrictSuffixOf returns true if the columns in c are a strict suffix of the columns in other.

func (Columns) String Uses

func (c Columns) String() string

type Constraint Uses

type Constraint struct {
    Columns Columns

    // Spans contains the spans in this constraint. The spans are always ordered
    // and non-overlapping.
    Spans Spans
}

Constraint specifies the possible set of values that one or more columns will have in the result set. If this is a single column constraint, then that column's value will always be part of one of the spans in this constraint. If this is a multi-column constraint, then the combination of column values will always be part of one of the spans.

Constrained columns are specified as an ordered list, and span key values correspond to those columns by position. Constraints are inferred from scalar filter conditions, since these restrict the set of possible results. Constraints over different combinations of columns can be combined together in a constraint set, which is a conjunction of constraints. See the Set struct comment for more details.

A few examples:

- a constraint on @1 > 1: a single span             /@1: (/1 - ]
- a constraint on @1 = 1 AND @2 >= 1: a single span /@1/@2: [/1/1 - /1]
- a constraint on @1 < 5 OR @1 > 10: multiple spans /@1: [ - /5) (10 - ]

func ParseConstraint Uses

func ParseConstraint(evalCtx *tree.EvalContext, str string) Constraint

ParseConstraint parses a constraint in the format of Constraint.String, e.g:

"/1/2/3: [/1 - /2]".

func (*Constraint) CalculateMaxResults Uses

func (c *Constraint) CalculateMaxResults(
    evalCtx *tree.EvalContext, indexCols opt.ColSet, notNullCols opt.ColSet,
) uint64

CalculateMaxResults returns a non-zero integer indicating the maximum number of results that can be read from indexCols by using c.Spans. The indexCols are assumed to form at least a weak key. If 0 is returned, the maximum number of results could not be deduced. We can calculate the maximum number of results when both of the following are satisfied:

1. The index columns form a weak key (assumption), and the spans do not
   specify any nulls.
2. All spans cover all the columns of the index and have equal start and
   end keys up to but not necessarily including the last column.

TODO(asubiotto): The only reason to extract this is that both the heuristic planner and optimizer need this logic, due to the heuristic planner planning mutations. Once the optimizer plans mutations, this method can go away.

func (*Constraint) Combine Uses

func (c *Constraint) Combine(evalCtx *tree.EvalContext, other *Constraint)

Combine refines the receiver constraint using constraints on a suffix of the same list of columns. For example:

c:      /a/b: [/1 - /2] [/4 - /4]
other:  /b: [/5 - /5]
result: /a/b: [/1/5 - /2/5] [/4/5 - /4/5]

func (*Constraint) ConsolidateSpans Uses

func (c *Constraint) ConsolidateSpans(evalCtx *tree.EvalContext)

ConsolidateSpans merges spans that have consecutive boundaries. For example:

[/1 - /2] [/3 - /4] becomes [/1 - /4].

func (*Constraint) ConstrainedColumns Uses

func (c *Constraint) ConstrainedColumns(evalCtx *tree.EvalContext) int

ConstrainedColumns returns the number of columns which are constrained by the Constraint. For example:

/a/b/c: [/1/1 - /1] [/3 - /3]

has 2 constrained columns. This may be less than the total number of columns in the constraint, especially if it represents an index constraint.

func (*Constraint) ContainsSpan Uses

func (c *Constraint) ContainsSpan(evalCtx *tree.EvalContext, sp *Span) bool

ContainsSpan returns true if the constraint contains the given span (or a span that contains it).

func (*Constraint) ExactPrefix Uses

func (c *Constraint) ExactPrefix(evalCtx *tree.EvalContext) int

ExactPrefix returns the length of the longest column prefix which are constrained to a single value. For example:

/a/b/c: [/1/2/3 - /1/2/3]                    ->  ExactPrefix = 3
/a/b/c: [/1/2/3 - /1/2/3] [/1/2/5 - /1/2/8]  ->  ExactPrefix = 2
/a/b/c: [/1/2/3 - /1/2/3] [/1/2/5 - /1/3/8]  ->  ExactPrefix = 1
/a/b/c: [/1/2/3 - /1/2/3] [/1/3/3 - /1/3/3]  ->  ExactPrefix = 1
/a/b/c: [/1/2/3 - /1/2/3] [/3 - /4]          ->  ExactPrefix = 0

func (*Constraint) ExtractConstCols Uses

func (c *Constraint) ExtractConstCols(evalCtx *tree.EvalContext) opt.ColSet

ExtractConstCols returns a set of columns which are restricted to be constant by the constraint.

func (*Constraint) ExtractNotNullCols Uses

func (c *Constraint) ExtractNotNullCols(evalCtx *tree.EvalContext) opt.ColSet

ExtractNotNullCols returns a set of columns that cannot be NULL when the constraint holds.

func (*Constraint) Init Uses

func (c *Constraint) Init(keyCtx *KeyContext, spans *Spans)

Init initializes the constraint to the columns in the key context and with the given spans.

func (*Constraint) InitSingleSpan Uses

func (c *Constraint) InitSingleSpan(keyCtx *KeyContext, span *Span)

InitSingleSpan initializes the constraint to the columns in the key context and with one span.

func (*Constraint) IntersectWith Uses

func (c *Constraint) IntersectWith(evalCtx *tree.EvalContext, other *Constraint)

IntersectWith intersects the spans of this constraint with those in the given constraint and updates this constraint with any overlapping spans. The columns of both constraints must be the same. If there are no overlapping spans, then the intersection is empty, and tryIntersectWith returns false. If a constraint set has even one empty constraint, then the entire set should be marked as empty and all constraints removed.

func (*Constraint) IsContradiction Uses

func (c *Constraint) IsContradiction() bool

IsContradiction returns true if there are no spans in the constraint.

func (*Constraint) IsUnconstrained Uses

func (c *Constraint) IsUnconstrained() bool

IsUnconstrained returns true if the constraint contains an unconstrained span.

func (*Constraint) Prefix Uses

func (c *Constraint) Prefix(evalCtx *tree.EvalContext) int

Prefix returns the length of the longest prefix of columns for which all the spans have the same start and end values. For example:

/a/b/c: [/1/1/1 - /1/1/2] [/3/3/3 - /3/3/4]

has prefix 2.

Note that Prefix returns a value that is greater than or equal to the value returned by ExactPrefix. For example:

/a/b/c: [/1/2/3 - /1/2/3] [/1/2/5 - /1/3/8] -> ExactPrefix = 1, Prefix = 1
/a/b/c: [/1/2/3 - /1/2/3] [/1/3/3 - /1/3/3] -> ExactPrefix = 1, Prefix = 3

func (Constraint) String Uses

func (c Constraint) String() string

func (*Constraint) UnionWith Uses

func (c *Constraint) UnionWith(evalCtx *tree.EvalContext, other *Constraint)

UnionWith merges the spans of the given constraint into this constraint. The columns of both constraints must be the same. Constrained columns in the merged constraint can have values that are part of either of the input constraints.

type Key Uses

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

Key is a composite of N typed datum values that are ordered from most significant to least significant for purposes of sorting. The datum values correspond to a set of columns; it is the responsibility of the calling code to keep track of them. Key is immutable; it cannot be changed once created.

func MakeCompositeKey Uses

func MakeCompositeKey(vals ...tree.Datum) Key

MakeCompositeKey constructs an N-dimensional key from the given slice of values.

func MakeKey Uses

func MakeKey(val tree.Datum) Key

MakeKey constructs a simple one dimensional key having the given value. If val is nil, then MakeKey returns an empty key.

func (Key) Compare Uses

func (k Key) Compare(keyCtx *KeyContext, l Key, kext, lext KeyExtension) int

Compare returns an integer indicating the ordering of the two keys. The result will be 0 if the keys are equal, -1 if this key is less than the given key, or 1 if this key is greater.

Comparisons between keys where one key is a prefix of the other have special handling which can be controlled via the key extension parameters. Key extensions specify whether each key is conceptually suffixed with negative or positive infinity for purposes of comparison. For example, if k is /1/2, then:

k (kExt = ExtendLow) : /1/2/Low
k (kExt = ExtendHigh): /1/2/High

These extensions have no effect if one key is not a prefix of the other, since the comparison would already have concluded in previous values. But if comparison proceeds all the way to the end of one of the keys, then the extension determines which key is greater. This enables correct comparison of start and end keys in spans which may be either inclusive or exclusive. Here is the mapping:

[/1/2 - ...] (inclusive start key): ExtendLow : /1/2/Low
(/1/2 - ...] (exclusive start key): ExtendHigh: /1/2/High
[... - /1/2] (inclusive end key)  : ExtendHigh: /1/2/High
[... - /1/2) (exclusive end key)  : ExtendLow : /1/2/Low

func (Key) Concat Uses

func (k Key) Concat(l Key) Key

Concat creates a new composite key by extending this key's values with the values of the given key. The new key's length is len(k) + len(l).

func (Key) CutFront Uses

func (k Key) CutFront(numCols int) Key

CutFront returns the key with the first numCols values removed. Example:

[/1/2 - /1/3].CutFront(1) = [/2 - /3]

func (Key) IsEmpty Uses

func (k Key) IsEmpty() bool

IsEmpty is true if this key has zero values.

func (Key) IsNextKey Uses

func (k Key) IsNextKey(keyCtx *KeyContext, other Key) bool

IsNextKey returns true if:

- k and other have the same length;
- on all but the last column, k and other have the same values;
- on the last column, k has the datum that follows other's datum (for
  types that support it).

For example: /2.IsNextKey(/1) is true.

func (Key) IsNull Uses

func (k Key) IsNull() bool

IsNull is true if this key is the NULL value.

func (Key) Length Uses

func (k Key) Length() int

Length returns the number of values in the key. If the count is zero, then this is an empty key.

func (Key) Next Uses

func (k Key) Next(keyCtx *KeyContext) (_ Key, ok bool)

Next returns the next key; this only works for discrete types like integers. It is guaranteed that there are no possible keys in the span

( key, Next(keu) ).

Examples:

Next(/1/2) = /1/3
Next(/1/false) = /1/true
Next(/1/true) returns !ok
Next(/'foo') = /'foo\x00'

If a column is descending, the values on that column go backwards:

Next(/2) = /1

The key cannot be empty.

func (Key) Prev Uses

func (k Key) Prev(keyCtx *KeyContext) (_ Key, ok bool)

Prev returns the next key; this only works for discrete types like integers.

Examples:

Prev(/1/2) = /1/1
Prev(/1/true) = /1/false
Prev(/1/false) returns !ok.
Prev(/'foo') returns !ok.

If a column is descending, the values on that column go backwards:

Prev(/1) = /2

If this is the minimum possible key, returns EmptyKey.

func (Key) String Uses

func (k Key) String() string

String formats a key like this:

EmptyKey         : empty string
Key with 1 value : /2
Key with 2 values: /5/1
Key with 3 values: /3/6/4

func (Key) Value Uses

func (k Key) Value(nth int) tree.Datum

Value returns the nth value of the key. If the index is out-of-range, then Value will panic.

type KeyContext Uses

type KeyContext struct {
    Columns Columns
    EvalCtx *tree.EvalContext
}

KeyContext contains the necessary metadata for comparing Keys.

func MakeKeyContext Uses

func MakeKeyContext(cols *Columns, evalCtx *tree.EvalContext) KeyContext

MakeKeyContext initializes a KeyContext.

func (*KeyContext) Compare Uses

func (c *KeyContext) Compare(colIdx int, a, b tree.Datum) int

Compare two values for a given column. Returns 0 if the values are equal, -1 if a is less than b, or 1 if b is less than a.

func (*KeyContext) Next Uses

func (c *KeyContext) Next(colIdx int, val tree.Datum) (_ tree.Datum, ok bool)

Next returns the next value on a given column (for discrete types like integers). See Datum.Next/Prev.

func (*KeyContext) Prev Uses

func (c *KeyContext) Prev(colIdx int, val tree.Datum) (_ tree.Datum, ok bool)

Prev returns the previous value on a given column (for discrete types like integers). See Datum.Next/Prev.

type KeyExtension Uses

type KeyExtension bool

KeyExtension is an enumeration used when comparing keys. Key extensions specify whether each key is conceptually suffixed with a value that sorts before all values (ExtendLow) or with a value that sorts after all values (ExtendHigh). This allows span boundaries to be compared with one another. See the comment for the Key.Compare method for more details.

const (
    // ExtendLow specifies that the key is conceptually suffixed with a value
    // that sorts before all values for purposes of comparison.
    ExtendLow KeyExtension = false

    // ExtendHigh specifies that the key is conceptually suffixed with a value
    // that sorts after all values for purposes of comparison.
    ExtendHigh KeyExtension = true
)

func (KeyExtension) ToCmp Uses

func (e KeyExtension) ToCmp() int

ToCmp converts from a key extension value to a comparison value. ExtendLow maps to -1 because it sorts before all other values. ExtendHigh maps to 1 because it sorts after all other values.

type Set Uses

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

Set is a conjunction of constraints that are inferred from scalar filter conditions. The constrained expression will always evaluate to a result set having values that conform to all of the constraints in the constraint set. Each constraint within the set is a disjunction of spans that together specify the domain of possible values which that constraint's column(s) can have. See the Constraint struct comment for more details.

Constraint sets are useful for selecting indexes, pruning ranges, inferring non-null columns, and more. They serve as a "summary" of arbitrarily complex expressions, so that fast decisions can be made without analyzing the entire expression tree each time.

A few examples:

- @1 >= 10
    /@1: [/10 - ]

- @1 > 10 AND @2 = 5
    /@1: [/11 - ]
    /@2: [/5 - /5]

- (@1 = 10 AND @2 > 5) OR (@1 = 20 AND @2 > 0)
    /@1: [/10 - /10] [/20 - /20]
    /@2: [/1 - ]

- @1 > 10.5 AND @2 != 'foo'
    /@1: (10.5 - ]
    /@2: [ - 'foo') ('foo' - ]

func SingleConstraint Uses

func SingleConstraint(c *Constraint) *Set

SingleConstraint creates a Set with a single Constraint.

func SingleSpanConstraint Uses

func SingleSpanConstraint(keyCtx *KeyContext, span *Span) *Set

SingleSpanConstraint creates a Set with a single constraint which has one span.

func (*Set) Constraint Uses

func (s *Set) Constraint(nth int) *Constraint

Constraint returns the nth constraint in the set. Together with the Length method, Constraint allows iteration over the list of constraints (since there is no method to return a slice of constraints).

func (*Set) ExtractCols Uses

func (s *Set) ExtractCols() opt.ColSet

ExtractCols returns all columns involved in the constraints in this set.

func (*Set) ExtractConstCols Uses

func (s *Set) ExtractConstCols(evalCtx *tree.EvalContext) opt.ColSet

ExtractConstCols returns a set of columns which can only have one value for the constraints in the set to hold.

func (*Set) ExtractNotNullCols Uses

func (s *Set) ExtractNotNullCols(evalCtx *tree.EvalContext) opt.ColSet

ExtractNotNullCols returns a set of columns that cannot be NULL for the constraints in the set to hold.

func (*Set) Intersect Uses

func (s *Set) Intersect(evalCtx *tree.EvalContext, other *Set) *Set

Intersect finds the overlap between this constraint set and the given set. Constraints that exist in either of the input sets will get merged into the combined set. Compatible constraints (that share same column list) are intersected with one another. Intersect returns the merged set.

func (*Set) IsUnconstrained Uses

func (s *Set) IsUnconstrained() bool

IsUnconstrained returns true if the constraint set contains no constraints, which means column values can have any possible values.

func (*Set) Length Uses

func (s *Set) Length() int

Length returns the number of constraints in the set.

func (*Set) String Uses

func (s *Set) String() string

func (*Set) Union Uses

func (s *Set) Union(evalCtx *tree.EvalContext, other *Set) *Set

Union creates a new set with constraints that allow any value that either of the input sets allowed. Compatible constraints (that share same column list) that exist in both sets are merged with one another. Note that the results may not be "tight", meaning that the new constraint set might allow additional combinations of values that neither of the input sets allowed. For example:

(x > 1 AND y > 10) OR (x < 5 AND y < 50)

the union is unconstrained (and thus allows combinations like x,y = 10,0).

Union returns the merged set.

type Span Uses

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

Span represents the range between two composite keys. The end keys of the range can be inclusive or exclusive. Each key value within the range is an N-tuple of datum values, one for each constrained column. Here are some examples:

@1 < 100                                          : [ - /100)
@1 >= 100                                         : [/100 - ]
@1 >= 1 AND @1 <= 10                              : [/1 - /10]
(@1 = 100 AND @2 > 10) OR (@1 > 100 AND @1 <= 101): (/100/10 - /101]

func ParseSpan Uses

func ParseSpan(evalCtx *tree.EvalContext, str string, typ types.Family) Span

ParseSpan parses a span in the format of Span.String, e.g: [/1 - /2].

func (*Span) Compare Uses

func (sp *Span) Compare(keyCtx *KeyContext, other *Span) int

Compare returns an integer indicating the ordering of the two spans. The result will be 0 if the spans are equal, -1 if this span is less than the given span, or 1 if this span is greater. Spans are first compared based on their start boundaries. If those are equal, then their end boundaries are compared. An inclusive start boundary is less than an exclusive start boundary, and an exclusive end boundary is less than an inclusive end boundary. Here are examples of how various spans are ordered, with equivalent extended keys shown as well (see Key.Compare comment):

[     - /2  )  =  /Low      - /2/Low
[     - /2/1)  =  /Low      - /2/1/Low
[     - /2/1]  =  /Low      - /2/1/High
[     - /2  ]  =  /Low      - /2/High
[     -     ]  =  /Low      - /High
[/1   - /2/1)  =  /1/Low    - /2/1/Low
[/1   - /2/1]  =  /1/Low    - /2/1/High
[/1   -     ]  =  /1/Low    - /High
[/1/1 - /2  )  =  /1/1/Low  - /2/Low
[/1/1 - /2  ]  =  /1/1/Low  - /2/High
[/1/1 -     ]  =  /1/1/Low  - /High
(/1/1 - /2  )  =  /1/1/High - /2/Low
(/1/1 - /2  ]  =  /1/1/High - /2/High
(/1/1 -     ]  =  /1/1/High - /High
(/1   - /2/1)  =  /1/High   - /2/1/Low
(/1   - /2/1]  =  /1/High   - /2/1/High
(/1   -     ]  =  /1/High   - /High

func (*Span) CompareEnds Uses

func (sp *Span) CompareEnds(keyCtx *KeyContext, other *Span) int

CompareEnds returns an integer indicating the ordering of the end boundaries of the two spans. The result will be 0 if the spans have the same end boundary, -1 if this span has a smaller end boundary than the given span, or 1 if this span has a bigger end boundary than the given span.

func (*Span) CompareStarts Uses

func (sp *Span) CompareStarts(keyCtx *KeyContext, other *Span) int

CompareStarts returns an integer indicating the ordering of the start boundaries of the two spans. The result will be 0 if the spans have the same start boundary, -1 if this span has a smaller start boundary than the given span, or 1 if this span has a bigger start boundary than the given span.

func (*Span) CutFront Uses

func (sp *Span) CutFront(numCols int)

CutFront removes the first numCols columns in both keys.

func (*Span) EndBoundary Uses

func (sp *Span) EndBoundary() SpanBoundary

EndBoundary returns whether the end key is included or excluded.

func (*Span) EndKey Uses

func (sp *Span) EndKey() Key

EndKey returns the end key.

func (*Span) Init Uses

func (sp *Span) Init(start Key, startBoundary SpanBoundary, end Key, endBoundary SpanBoundary)

Init sets the boundaries of this span to the given values. The following spans are not allowed:

1. Empty span (should never be used in a constraint); not verified.
2. Exclusive empty key boundary (use inclusive instead); causes panic.

func (*Span) IsUnconstrained Uses

func (sp *Span) IsUnconstrained() bool

IsUnconstrained is true if the span does not constrain the key range. Both the start and end boundaries are empty. This is the default state of a Span before Set is called. Unconstrained spans cannot be used in constraints, since the absence of a constraint is equivalent to an unconstrained span.

func (*Span) PreferInclusive Uses

func (sp *Span) PreferInclusive(keyCtx *KeyContext)

PreferInclusive tries to convert exclusive keys to inclusive keys. This is only possible if the relevant type supports Next/Prev.

We prefer inclusive constraints because we can extend inclusive constraints with more constraints on columns that follow.

Examples:

- for an integer column (/1 - /5)  =>  [/2 - /4].
- for a descending integer column (/5 - /1) => (/4 - /2).
- for a string column, we don't have Prev so
    (/foo - /qux)  =>  [/foo\x00 - /qux).
- for a decimal column, we don't have either Next or Prev so we can't
  change anything.

func (*Span) StartBoundary Uses

func (sp *Span) StartBoundary() SpanBoundary

StartBoundary returns whether the start key is included or excluded.

func (*Span) StartKey Uses

func (sp *Span) StartKey() Key

StartKey returns the start key.

func (*Span) StartsAfter Uses

func (sp *Span) StartsAfter(keyCtx *KeyContext, other *Span) bool

StartsAfter returns true if this span is greater than the given span and does not overlap it. In other words, this span's start boundary is greater or equal to the given span's end boundary.

func (*Span) StartsStrictlyAfter Uses

func (sp *Span) StartsStrictlyAfter(keyCtx *KeyContext, other *Span) bool

StartsStrictlyAfter returns true if this span is greater than the given span and does not overlap or touch it. In other words, this span's start boundary is strictly greater than the given span's end boundary.

func (Span) String Uses

func (sp Span) String() string

String formats a Span. Inclusivity/exclusivity is shown using brackets/parens. Some examples:

[1 - 2]
(1/1 - 2)
[ - 5/6)
[1 - ]
[ - ]

func (*Span) TryIntersectWith Uses

func (sp *Span) TryIntersectWith(keyCtx *KeyContext, other *Span) bool

TryIntersectWith finds the overlap between this span and the given span. This span is updated to only cover the range that is common to both spans. If there is no overlap, then this span will not be updated, and TryIntersectWith will return false.

func (*Span) TryUnionWith Uses

func (sp *Span) TryUnionWith(keyCtx *KeyContext, other *Span) bool

TryUnionWith attempts to merge this span with the given span. If the merged spans cannot be expressed as a single span, then TryUnionWith will not update the span and TryUnionWith returns false. This could occur if the spans are disjoint, for example:

[/1 - /5] UNION [/10 - /15]

Otherwise, this span is updated to the merged span range and TryUnionWith returns true. If the resulting span does not constrain the range [ - ], then its IsUnconstrained method returns true, and it cannot be used as part of a constraint in a constraint set.

type SpanBoundary Uses

type SpanBoundary bool

SpanBoundary specifies whether a span endpoint is inclusive or exclusive of its start or end key. An inclusive boundary is represented as '[' and an exclusive boundary is represented as ')'. Examples:

[/0 - /1]  (inclusive, inclusive)
[/1 - /10) (inclusive, exclusive)
const (
    // IncludeBoundary indicates that the boundary does include the respective
    // key.
    IncludeBoundary SpanBoundary = false

    // ExcludeBoundary indicates that the boundary does not include the
    // respective key.
    ExcludeBoundary SpanBoundary = true
)

type Spans Uses

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

Spans is a collection of spans. There are no general requirements on the contents of the spans in the structure; the caller has to make sure they make sense in the respective context.

func (*Spans) Alloc Uses

func (s *Spans) Alloc(capacity int)

Alloc allocates enough space to support the given amount of spans without reallocation. Does nothing if the structure already contains spans.

func (*Spans) Append Uses

func (s *Spans) Append(sp *Span)

Append adds another span (at the end).

func (*Spans) Count Uses

func (s *Spans) Count() int

Count returns the number of spans.

func (*Spans) Get Uses

func (s *Spans) Get(nth int) *Span

Get returns the nth span.

func (*Spans) InitSingleSpan Uses

func (s *Spans) InitSingleSpan(sp *Span)

InitSingleSpan initializes the structure with a single span.

func (*Spans) SortAndMerge Uses

func (s *Spans) SortAndMerge(keyCtx *KeyContext)

SortAndMerge sorts the spans and merges any overlapping spans.

func (Spans) String Uses

func (s Spans) String() string

func (*Spans) Truncate Uses

func (s *Spans) Truncate(newLength int)

Truncate removes all but the first newLength spans.

Package constraint imports 10 packages (graph) and is imported by 8 packages. Updated 2019-09-08. Refresh now. Tools for package owners.