distsqlplan

package
v0.0.0-...-b3f1699 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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().

Jump to

Keyboard shortcuts

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