Documentation ¶
Index ¶
- Variables
- type DistAggregationInfo
- type LeaseHolderChoosingPolicy
- type SpanResolver
- type SpanResolverIterator
- func (it *SpanResolverIterator) Desc() roachpb.RangeDescriptor
- func (it *SpanResolverIterator) Error() error
- func (it *SpanResolverIterator) NeedAnother() bool
- func (it *SpanResolverIterator) Next(ctx context.Context)
- func (it *SpanResolverIterator) ReplicaInfo(ctx context.Context) (kv.ReplicaInfo, error)
- func (it *SpanResolverIterator) Seek(ctx context.Context, span roachpb.Span, scanDir kv.ScanDirection)
- func (it *SpanResolverIterator) Valid() bool
Constants ¶
This section is empty.
Variables ¶
var DistAggregationTable = map[distsqlrun.AggregatorSpec_Func]DistAggregationInfo{ distsqlrun.AggregatorSpec_IDENT: { LocalStage: distsqlrun.AggregatorSpec_IDENT, FinalStage: distsqlrun.AggregatorSpec_IDENT, }, distsqlrun.AggregatorSpec_BOOL_AND: { LocalStage: distsqlrun.AggregatorSpec_BOOL_AND, FinalStage: distsqlrun.AggregatorSpec_BOOL_AND, }, distsqlrun.AggregatorSpec_BOOL_OR: { LocalStage: distsqlrun.AggregatorSpec_BOOL_OR, FinalStage: distsqlrun.AggregatorSpec_BOOL_OR, }, distsqlrun.AggregatorSpec_COUNT: { LocalStage: distsqlrun.AggregatorSpec_COUNT, FinalStage: distsqlrun.AggregatorSpec_SUM_INT, }, distsqlrun.AggregatorSpec_MAX: { LocalStage: distsqlrun.AggregatorSpec_MAX, FinalStage: distsqlrun.AggregatorSpec_MAX, }, distsqlrun.AggregatorSpec_MIN: { LocalStage: distsqlrun.AggregatorSpec_MIN, FinalStage: distsqlrun.AggregatorSpec_MIN, }, distsqlrun.AggregatorSpec_SUM: { LocalStage: distsqlrun.AggregatorSpec_SUM, FinalStage: distsqlrun.AggregatorSpec_SUM, }, }
DistAggregationTable is DistAggregationInfo look-up table. Functions that don't have an entry in the table are not optimized with a local stage.
Functions ¶
This section is empty.
Types ¶
type DistAggregationInfo ¶
type DistAggregationInfo struct { LocalStage distsqlrun.AggregatorSpec_Func FinalStage distsqlrun.AggregatorSpec_Func }
DistAggregationInfo describes how we can best compute a distributed aggregation. If we have multiple sources of data, we first compute a function on each group ("local stage") and then we aggregate those results (final "stage").
type LeaseHolderChoosingPolicy ¶
type LeaseHolderChoosingPolicy byte
LeaseHolderChoosingPolicy enumerates the implementors of leaseHolderOracle.
const ( // RandomLeaseHolderChoice chooses lease holders randomly. RandomLeaseHolderChoice LeaseHolderChoosingPolicy = iota // BinPackingLeaseHolderChoice bin-packs the choices. BinPackingLeaseHolderChoice )
type SpanResolver ¶
type SpanResolver struct {
// contains filtered or unexported fields
}
SpanResolver resolves key spans to their respective ranges and lease holders. Used for planning physical execution of distributed SQL queries.
Sample usage for resolving a bunch of spans:
func resolveSpans(
ctx context.Context, it *distsql.SpanResolverIterator, spans ...spanWithDir,
) ([][]kv.ReplicaInfo, error) { lr := distsql.NewSpanResolver( distSender, gossip, nodeDescriptor, distsql.BinPackingLeaseHolderChoice) it := lr.NewSpanResolverIterator() res := make([][]kv.ReplicaInfo, 0) for _, span := range spans { repls := make([]kv.ReplicaInfo, 0) for it.Seek(ctx, span.Span, span.dir); ; it.Next(ctx) { if !it.Valid() { return nil, it.Error() } repl, err := it.ReplicaInfo(ctx) if err != nil { return nil, err } repls = append(repls, repl) if !it.NeedAnother() { break } } res = append(res, repls) } return res, nil }
func NewSpanResolver ¶
func NewSpanResolver( distSender *kv.DistSender, gossip *gossip.Gossip, nodeDesc roachpb.NodeDescriptor, choosingPolicy LeaseHolderChoosingPolicy, ) *SpanResolver
NewSpanResolver creates a new SpanResolver.
func (*SpanResolver) NewSpanResolverIterator ¶
func (sr *SpanResolver) NewSpanResolverIterator() *SpanResolverIterator
NewSpanResolverIterator creates a new SpanResolverIterator.
type SpanResolverIterator ¶
type SpanResolverIterator struct {
// contains filtered or unexported fields
}
SpanResolverIterator iterates over the ranges composing a key span.
func (*SpanResolverIterator) Desc ¶
func (it *SpanResolverIterator) Desc() roachpb.RangeDescriptor
Desc returns the current RangeDescriptor.
func (*SpanResolverIterator) Error ¶
func (it *SpanResolverIterator) Error() error
func (*SpanResolverIterator) NeedAnother ¶
func (it *SpanResolverIterator) NeedAnother() bool
NeedAnother returns true if the current range is not the last for the span that was last Seek()ed.
func (*SpanResolverIterator) Next ¶
func (it *SpanResolverIterator) Next(ctx context.Context)
Next advances the iterator to the next range. Possible errors encountered should be checked for with Valid().
func (*SpanResolverIterator) ReplicaInfo ¶
func (it *SpanResolverIterator) ReplicaInfo(ctx context.Context) (kv.ReplicaInfo, error)
ReplicaInfo returns information about the replica that has been picked for the current range. A RangeUnavailableError is returned if there's no information in gossip about any of the replicas.
func (*SpanResolverIterator) Seek ¶
func (it *SpanResolverIterator) Seek( ctx context.Context, span roachpb.Span, scanDir kv.ScanDirection, )
Seek positions the iterator on the start of a span (span.Key or span.EndKey, depending on ScanDir). Note that span.EndKey is exclusive, regardless of scanDir. After calling this, ReplicaInfo() will return information about the range containing the start key of the span (or the end key, if the direction is Descending). NeedAnother() will return true until the iterator is positioned on or after the end of the span. Possible errors encountered should be checked for with Valid().
Seek can be called repeatedly on the same iterator. To make optimal uses of caches, Seek()s should be performed on spans sorted according to the scanDir (if Descending, then the span with the highest keys should be Seek()ed first).
scanDir changes the direction in which Next() will advance the iterator.
func (*SpanResolverIterator) Valid ¶
func (it *SpanResolverIterator) Valid() bool
Valid returns false if an error was encoutered by the last Seek() or Next().