github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/colexec/execgen/cmd/execgen/vec_comparators_gen.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package main 12 13 import ( 14 "io" 15 "strings" 16 "text/template" 17 18 "github.com/cockroachdb/cockroachdb-parser/pkg/sql/sem/tree/treecmp" 19 ) 20 21 const vecCmpTmpl = "pkg/sql/colexec/vec_comparators_tmpl.go" 22 23 func genVecComparators(inputFileContents string, wr io.Writer) error { 24 r := strings.NewReplacer( 25 "_CANONICAL_TYPE_FAMILY", "{{.CanonicalTypeFamilyStr}}", 26 "_TYPE_WIDTH", typeWidthReplacement, 27 "_GOTYPESLICE", "{{.GoTypeSliceName}}", 28 "_TYPE", "{{.VecMethod}}", 29 ) 30 s := r.Replace(inputFileContents) 31 32 compareRe := makeFunctionRegex("_COMPARE", 5) 33 s = compareRe.ReplaceAllString(s, makeTemplateFunctionCall("Compare", 5)) 34 35 s = replaceManipulationFuncs(s) 36 37 tmpl, err := template.New("vec_comparators").Parse(s) 38 if err != nil { 39 return err 40 } 41 42 return tmpl.Execute(wr, sameTypeComparisonOpToOverloads[treecmp.EQ]) 43 } 44 45 func init() { 46 registerGenerator(genVecComparators, "vec_comparators.eg.go", vecCmpTmpl) 47 }