Documentation
¶
Index ¶
- type Builder
- func (s *Builder) Init(evalCtx *tree.EvalContext, codec keys.SQLCodec, table catalog.TableDescriptor, ...)
- func (s *Builder) InitWithFetchSpec(evalCtx *tree.EvalContext, codec keys.SQLCodec, spec *descpb.IndexFetchSpec)
- func (s *Builder) SpanFromDatumRow(values tree.Datums, prefixLen int, colMap catalog.TableColMap) (_ roachpb.Span, containsNull bool, _ error)
- func (s *Builder) SpanFromEncDatums(values rowenc.EncDatumRow) (_ roachpb.Span, containsNull bool, _ error)
- func (s *Builder) SpanFromEncDatumsWithRange(values rowenc.EncDatumRow, prefixLen int, startDatum tree.Datum, ...) (_ roachpb.Span, containsNull bool, err error)
- func (s *Builder) SpanToPointSpan(span roachpb.Span, family descpb.FamilyID) roachpb.Span
- func (s *Builder) SpansFromConstraint(c *constraint.Constraint, splitter Splitter) (roachpb.Spans, error)
- func (s *Builder) SpansFromInvertedSpans(invertedSpans InvertedSpans, c *constraint.Constraint, scratch roachpb.Spans) (roachpb.Spans, error)
- func (s *Builder) UnconstrainedSpans() (roachpb.Spans, error)
- type InvertedSpans
- type Splitter
- func (s *Splitter) CanSplitSpanIntoFamilySpans(prefixLen int, containsNull bool) bool
- func (s *Splitter) ExistenceCheckSpan(span roachpb.Span, prefixLen int, containsNull bool) roachpb.Span
- func (s *Splitter) FamilyIDs() []descpb.FamilyID
- func (s *Splitter) IsNoop() bool
- func (s *Splitter) MaybeSplitSpanIntoSeparateFamilies(appendTo roachpb.Spans, span roachpb.Span, prefixLen int, containsNull bool) roachpb.Spans
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// KeyPrefix is the prefix of keys generated by the builder.
KeyPrefix []byte
// contains filtered or unexported fields
}
Builder is a single struct for generating key spans from Constraints, Datums, encDatums, and InvertedSpans.
func (*Builder) Init ¶
func (s *Builder) Init( evalCtx *tree.EvalContext, codec keys.SQLCodec, table catalog.TableDescriptor, index catalog.Index, )
Init initializes a Builder with a table and index.
func (*Builder) InitWithFetchSpec ¶
func (s *Builder) InitWithFetchSpec( evalCtx *tree.EvalContext, codec keys.SQLCodec, spec *descpb.IndexFetchSpec, )
InitWithFetchSpec creates a Builder using IndexFetchSpec.
func (*Builder) SpanFromDatumRow ¶
func (s *Builder) SpanFromDatumRow( values tree.Datums, prefixLen int, colMap catalog.TableColMap, ) (_ roachpb.Span, containsNull bool, _ error)
SpanFromDatumRow generates an index span with prefixLen constraint columns from the index. SpanFromDatumRow assumes that values is a valid table row for the Builder's table. It also returns whether the input values contain a null value or not, which can be used as input for CanSplitSpanIntoFamilySpans.
func (*Builder) SpanFromEncDatums ¶
func (s *Builder) SpanFromEncDatums( values rowenc.EncDatumRow, ) (_ roachpb.Span, containsNull bool, _ error)
SpanFromEncDatums encodes a span with len(values) constraint columns from the index prefixed with the index key prefix that includes the table and index ID. SpanFromEncDatums assumes that the EncDatums in values are in the order of the index columns. It also returns whether the input values contain a null value or not, which can be used as input for CanSplitSpanIntoFamilySpans.
func (*Builder) SpanFromEncDatumsWithRange ¶
func (s *Builder) SpanFromEncDatumsWithRange( values rowenc.EncDatumRow, prefixLen int, startDatum tree.Datum, startInclusive bool, endDatum tree.Datum, endInclusive bool, ) (_ roachpb.Span, containsNull bool, err error)
SpanFromEncDatumsWithRange encodes a range span. The inequality is assumed to be the end of the span and the start/end keys are generated by putting them in the values row at the prefixLen - 1 position. Only one of start or end need be non-nil, omitted one causing an open ended range span to be generated. Since the exec code knows nothing about index column sorting direction we assume ascending if they are descending we deal with that here.
func (*Builder) SpanToPointSpan ¶
SpanToPointSpan converts a span into a span that represents a point lookup on a specific family. It is up to the caller to ensure that this is a safe operation, by calling CanSplitSpanIntoFamilySpans before using it.
func (*Builder) SpansFromConstraint ¶
func (s *Builder) SpansFromConstraint( c *constraint.Constraint, splitter Splitter, ) (roachpb.Spans, error)
SpansFromConstraint generates spans from an optimizer constraint. A span.Splitter can be used to generate more specific family spans.
TODO (rohany): In future work, there should be a single API to generate spans
from constraints, datums and encdatums.
func (*Builder) SpansFromInvertedSpans ¶
func (s *Builder) SpansFromInvertedSpans( invertedSpans InvertedSpans, c *constraint.Constraint, scratch roachpb.Spans, ) (roachpb.Spans, error)
SpansFromInvertedSpans constructs spans to scan an inverted index.
If the index is a single-column inverted index, c should be nil.
If the index is a multi-column inverted index, c should constrain the non-inverted prefix columns of the index. Each span in c must have a single key. The resulting roachpb.Spans are created by performing a cross product of keys in c and the invertedSpan keys.
scratch can be an optional roachpb.Spans slice that will be reused to populate the result.
type InvertedSpans ¶
type InvertedSpans interface {
// Len returns the number of spans represented.
Len() int
// Start returns the start bytes of the ith span.
Start(i int) []byte
// End returns the end bytes of the ith span.
End(i int) []byte
}
InvertedSpans represent inverted index spans that can be encoded into key spans.
type Splitter ¶
type Splitter struct {
// contains filtered or unexported fields
}
Splitter is a helper for splitting single-row spans into more specific spans that target a subset of column families.
Note that a zero Splitter (NoopSplitter) is a usable instance that never splits spans.
func MakeSplitter ¶
func MakeSplitter( table catalog.TableDescriptor, index catalog.Index, neededColOrdinals util.FastIntSet, ) Splitter
MakeSplitter returns a Splitter that splits spans into more specific spans for the needed families. If span splitting is not possible/useful, returns the NoopSplitter (which never splits).
func MakeSplitterWithFamilyIDs ¶
MakeSplitterWithFamilyIDs creates a Splitter that splits spans that constrain all key columns along the given family IDs.
Returns NoopSplitter if familyIDs is empty.
This should only be used when the conditions checked by MakeSplitter are already known to be satisfied.
func NoopSplitter ¶
func NoopSplitter() Splitter
NoopSplitter returns a splitter that never splits spans.
func (*Splitter) CanSplitSpanIntoFamilySpans ¶
CanSplitSpanIntoFamilySpans returns whether a span encoded with prefixLen encoded columns can be safely split into 1 or more family specific spans.
func (*Splitter) ExistenceCheckSpan ¶
func (s *Splitter) ExistenceCheckSpan( span roachpb.Span, prefixLen int, containsNull bool, ) roachpb.Span
ExistenceCheckSpan returns a span that can be used to check whether a row exists: when there are multiple families, we narrow down the span to family 0.
func (*Splitter) FamilyIDs ¶
FamilyIDs returns the family IDs into which spans will be split, or nil if splitting is not possible.
func (*Splitter) MaybeSplitSpanIntoSeparateFamilies ¶
func (s *Splitter) MaybeSplitSpanIntoSeparateFamilies( appendTo roachpb.Spans, span roachpb.Span, prefixLen int, containsNull bool, ) roachpb.Spans
MaybeSplitSpanIntoSeparateFamilies uses the needed columns configured by MakeSplitter to conditionally split the input span into multiple family specific spans.
prefixLen is the number of index columns encoded in the span. containsNull indicates if one of the encoded columns was NULL.
The function accepts a slice of spans to append to.