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

     1  // Copyright 2024 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/common/mpool"
    19  	"github.com/matrixorigin/matrixone/pkg/common/reuse"
    20  	"github.com/matrixorigin/matrixone/pkg/container/types"
    21  	"github.com/matrixorigin/matrixone/pkg/container/vector"
    22  )
    23  
    24  func init() {
    25  
    26  	reuse.CreatePool[FixedVectorExpressionExecutor](
    27  		func() *FixedVectorExpressionExecutor {
    28  			return &FixedVectorExpressionExecutor{}
    29  		},
    30  		func(s *FixedVectorExpressionExecutor) { *s = FixedVectorExpressionExecutor{} },
    31  		reuse.DefaultOptions[FixedVectorExpressionExecutor]().
    32  			WithEnableChecker(),
    33  	)
    34  
    35  	reuse.CreatePool[ColumnExpressionExecutor](
    36  		func() *ColumnExpressionExecutor {
    37  			return &ColumnExpressionExecutor{}
    38  		},
    39  		func(s *ColumnExpressionExecutor) { *s = ColumnExpressionExecutor{} },
    40  		reuse.DefaultOptions[ColumnExpressionExecutor]().
    41  			WithEnableChecker(),
    42  	)
    43  
    44  	reuse.CreatePool[ParamExpressionExecutor](
    45  		func() *ParamExpressionExecutor {
    46  			return &ParamExpressionExecutor{}
    47  		},
    48  		func(s *ParamExpressionExecutor) { *s = ParamExpressionExecutor{} },
    49  		reuse.DefaultOptions[ParamExpressionExecutor]().
    50  			WithEnableChecker(),
    51  	)
    52  
    53  	reuse.CreatePool[VarExpressionExecutor](
    54  		func() *VarExpressionExecutor {
    55  			return &VarExpressionExecutor{}
    56  		},
    57  		func(s *VarExpressionExecutor) { *s = VarExpressionExecutor{} },
    58  		reuse.DefaultOptions[VarExpressionExecutor]().
    59  			WithEnableChecker(),
    60  	)
    61  
    62  	reuse.CreatePool[FunctionExpressionExecutor](
    63  		func() *FunctionExpressionExecutor {
    64  			return &FunctionExpressionExecutor{}
    65  		},
    66  		func(s *FunctionExpressionExecutor) { *s = FunctionExpressionExecutor{} },
    67  		reuse.DefaultOptions[FunctionExpressionExecutor]().
    68  			WithEnableChecker(),
    69  	)
    70  
    71  }
    72  
    73  func (expr FixedVectorExpressionExecutor) TypeName() string {
    74  	return "FixedVectorExpressionExecutor"
    75  }
    76  
    77  func NewFixedVectorExpressionExecutor(m *mpool.MPool, fixed bool, resultVector *vector.Vector) *FixedVectorExpressionExecutor {
    78  	fe := reuse.Alloc[FixedVectorExpressionExecutor](nil)
    79  	*fe = FixedVectorExpressionExecutor{
    80  		m:            m,
    81  		fixed:        fixed,
    82  		resultVector: resultVector,
    83  	}
    84  	return fe
    85  }
    86  
    87  func (expr ColumnExpressionExecutor) TypeName() string {
    88  	return "ColumnExpressionExecutor"
    89  }
    90  
    91  func NewColumnExpressionExecutor() *ColumnExpressionExecutor {
    92  	ce := reuse.Alloc[ColumnExpressionExecutor](nil)
    93  	return ce
    94  }
    95  
    96  func (expr ParamExpressionExecutor) TypeName() string {
    97  	return "ParamExpressionExecutor"
    98  }
    99  
   100  func NewParamExpressionExecutor(mp *mpool.MPool, pos int, typ types.Type) *ParamExpressionExecutor {
   101  	pe := reuse.Alloc[ParamExpressionExecutor](nil)
   102  	*pe = ParamExpressionExecutor{
   103  		mp:  mp,
   104  		pos: pos,
   105  		typ: typ,
   106  	}
   107  	return pe
   108  }
   109  
   110  func (expr VarExpressionExecutor) TypeName() string {
   111  	return "VarExpressionExecutor"
   112  }
   113  
   114  func NewVarExpressionExecutor() *VarExpressionExecutor {
   115  	ve := reuse.Alloc[VarExpressionExecutor](nil)
   116  	return ve
   117  }
   118  
   119  func (expr FunctionExpressionExecutor) TypeName() string {
   120  	return "FunctionExpressionExecutor"
   121  }
   122  
   123  func NewFunctionExpressionExecutor() *FunctionExpressionExecutor {
   124  	fe := reuse.Alloc[FunctionExpressionExecutor](nil)
   125  	return fe
   126  }