github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/colexec/types.go (about)

     1  // Copyright 2021 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 colexec
    16  
    17  import (
    18  	"github.com/matrixorigin/matrixone/pkg/container/batch"
    19  	"reflect"
    20  	"sync"
    21  
    22  	"github.com/google/uuid"
    23  	"github.com/matrixorigin/matrixone/pkg/logservice"
    24  	"github.com/matrixorigin/matrixone/pkg/objectio"
    25  	"github.com/matrixorigin/matrixone/pkg/vm/process"
    26  )
    27  
    28  type ResultPos struct {
    29  	Rel int32
    30  	Pos int32
    31  }
    32  
    33  func NewResultPos(rel int32, pos int32) ResultPos {
    34  	return ResultPos{Rel: rel, Pos: pos}
    35  }
    36  
    37  // ReceiveInfo used to spec which node,
    38  // and which registers you need
    39  type ReceiveInfo struct {
    40  	// it's useless
    41  	NodeAddr string
    42  	Uuid     uuid.UUID
    43  }
    44  
    45  // Server used to support cn2s3 directly, for more info, refer to docs about it
    46  type Server struct {
    47  	sync.Mutex
    48  
    49  	hakeeper      logservice.CNHAKeeperClient
    50  	uuidCsChanMap UuidProcMap
    51  	//txn's local segments.
    52  	cnSegmentMap CnSegmentMap
    53  }
    54  
    55  type uuidProcMapItem struct {
    56  	proc *process.Process
    57  }
    58  
    59  type UuidProcMap struct {
    60  	sync.Mutex
    61  	mp map[uuid.UUID]uuidProcMapItem
    62  }
    63  
    64  type CnSegmentMap struct {
    65  	sync.Mutex
    66  	// tag whether a segment is generated by this txn
    67  	// segmentName => uuid + file number
    68  	// 1.mp[segmentName] = 1 => txnWorkSpace
    69  	// 2.mp[segmentName] = 2 => Cn Blcok
    70  	mp map[objectio.Segmentid]int32
    71  }
    72  
    73  // ReceiverOperator need to receive batch from proc.Reg.MergeReceivers
    74  type ReceiverOperator struct {
    75  	proc *process.Process
    76  
    77  	// parameter for Merge-Type receiver.
    78  	// Merge-Type specifys the operator receive batch from all
    79  	// regs or single reg.
    80  	//
    81  	// Merge/MergeGroup/MergeLimit ... are Merge-Type
    82  	// while Join/Intersect/Minus ... are not
    83  	aliveMergeReceiver int
    84  	chs                []chan *batch.Batch
    85  	receiverListener   []reflect.SelectCase
    86  }
    87  
    88  const (
    89  	DefaultBatchSize = 8192
    90  )