github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/process/runtimeFilterMsg.go (about)

     1  // Copyright 2022 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package process
    16  
    17  import "github.com/matrixorigin/matrixone/pkg/pb/plan"
    18  
    19  const (
    20  	RuntimeFilter_IN          = 0
    21  	RuntimeFilter_BITMAP      = 1
    22  	RuntimeFilter_MIN_MAX     = 2
    23  	RuntimeFilter_BINARY_FUSE = 3
    24  	RuntimeFilter_PASS        = 100
    25  	RuntimeFilter_DROP        = 101
    26  )
    27  
    28  var _ Message = new(RuntimeFilterMessage)
    29  
    30  type RuntimeFilterMessage struct {
    31  	Tag  int32
    32  	Typ  int32
    33  	Card int32
    34  	Data []byte
    35  }
    36  
    37  func (rt RuntimeFilterMessage) Serialize() []byte {
    38  	panic("runtime filter message only broadcasts on current CN, don't need to serialize")
    39  }
    40  
    41  func (rt RuntimeFilterMessage) Deserialize([]byte) Message {
    42  	panic("runtime filter message only broadcasts on current CN, don't need to deserialize")
    43  }
    44  
    45  func (rt RuntimeFilterMessage) NeedBlock() bool {
    46  	return true
    47  }
    48  
    49  func (rt RuntimeFilterMessage) GetMsgTag() int32 {
    50  	return rt.Tag
    51  }
    52  
    53  func (rt RuntimeFilterMessage) GetReceiverAddr() MessageAddress {
    54  	return AddrBroadCastOnCurrentCN()
    55  }
    56  
    57  func (proc *Process) SendRuntimeFilter(rt RuntimeFilterMessage, m *plan.RuntimeFilterSpec) {
    58  	if m != nil {
    59  		proc.SendMessage(rt)
    60  		m.Handled = true
    61  	}
    62  }
    63  
    64  func (proc *Process) FinalizeRuntimeFilter(m *plan.RuntimeFilterSpec) {
    65  	if m != nil && !m.Handled {
    66  		var runtimeFilter RuntimeFilterMessage
    67  		runtimeFilter.Tag = m.Tag
    68  		runtimeFilter.Typ = RuntimeFilter_DROP
    69  		proc.SendMessage(runtimeFilter)
    70  	}
    71  	if m != nil {
    72  		m.Handled = false
    73  	}
    74  }