vitess.io/vitess@v0.16.2/go/vt/vtgate/planbuilder/operators/horizon.go (about)

     1  /*
     2  Copyright 2022 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package operators
    18  
    19  import (
    20  	"vitess.io/vitess/go/vt/sqlparser"
    21  	"vitess.io/vitess/go/vt/vtgate/planbuilder/operators/ops"
    22  	"vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext"
    23  )
    24  
    25  // Horizon is an operator we use until we decide how to handle the source to the horizon.
    26  // It contains information about the planning we have to do after deciding how we will send the query to the tablets.
    27  type Horizon struct {
    28  	Source ops.Operator
    29  	Select sqlparser.SelectStatement
    30  
    31  	noColumns
    32  }
    33  
    34  var _ ops.Operator = (*Horizon)(nil)
    35  var _ ops.PhysicalOperator = (*Horizon)(nil)
    36  
    37  func (h *Horizon) IPhysical() {}
    38  
    39  func (h *Horizon) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error) {
    40  	newSrc, err := h.Source.AddPredicate(ctx, expr)
    41  	if err != nil {
    42  		return nil, err
    43  	}
    44  	h.Source = newSrc
    45  	return h, nil
    46  }
    47  
    48  func (h *Horizon) Clone(inputs []ops.Operator) ops.Operator {
    49  	return &Horizon{
    50  		Source: inputs[0],
    51  		Select: h.Select,
    52  	}
    53  }
    54  
    55  func (h *Horizon) Inputs() []ops.Operator {
    56  	return []ops.Operator{h.Source}
    57  }