github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/compile/reuse.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 compile 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/vm/process" 19 "sync" 20 "sync/atomic" 21 22 "github.com/matrixorigin/matrixone/pkg/perfcounter" 23 24 "github.com/matrixorigin/matrixone/pkg/common/reuse" 25 ) 26 27 func init() { 28 reuse.CreatePool[Compile]( 29 func() *Compile { 30 return &Compile{ 31 affectRows: &atomic.Uint64{}, 32 lock: &sync.RWMutex{}, 33 counterSet: &perfcounter.CounterSet{}, 34 nodeRegs: make(map[[2]int32]*process.WaitRegister), 35 stepRegs: make(map[int32][][2]int32), 36 metaTables: make(map[string]struct{}), 37 MessageBoard: process.NewMessageBoard(), 38 } 39 }, 40 func(c *Compile) { 41 c.reset() 42 }, 43 reuse.DefaultOptions[Compile](). 44 WithEnableChecker(), 45 ) 46 47 reuse.CreatePool[Scope]( 48 func() *Scope { 49 return &Scope{} 50 }, 51 func(s *Scope) { *s = Scope{} }, 52 reuse.DefaultOptions[Scope](). 53 WithEnableChecker(), 54 ) 55 56 reuse.CreatePool[anaylze]( 57 func() *anaylze { 58 return &anaylze{} 59 }, 60 func(a *anaylze) { *a = anaylze{} }, 61 reuse.DefaultOptions[anaylze](). 62 WithEnableChecker(), 63 ) 64 65 reuse.CreatePool[fuzzyCheck]( 66 func() *fuzzyCheck { 67 return &fuzzyCheck{} 68 }, 69 func(f *fuzzyCheck) { f.reset() }, 70 reuse.DefaultOptions[fuzzyCheck](). 71 WithEnableChecker(), 72 ) 73 }