vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletserver/rules/cached_size.go (about) 1 /* 2 Copyright 2021 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 // Code generated by Sizegen. DO NOT EDIT. 17 18 package rules 19 20 import hack "vitess.io/vitess/go/hack" 21 22 type cachedObject interface { 23 CachedSize(alloc bool) int64 24 } 25 26 func (cached *BindVarCond) CachedSize(alloc bool) int64 { 27 if cached == nil { 28 return int64(0) 29 } 30 size := int64(0) 31 if alloc { 32 size += int64(48) 33 } 34 // field name string 35 size += hack.RuntimeAllocSize(int64(len(cached.name))) 36 // field value vitess.io/vitess/go/vt/vttablet/tabletserver/rules.bvcValue 37 if cc, ok := cached.value.(cachedObject); ok { 38 size += cc.CachedSize(true) 39 } 40 return size 41 } 42 func (cached *Rule) CachedSize(alloc bool) int64 { 43 if cached == nil { 44 return int64(0) 45 } 46 size := int64(0) 47 if alloc { 48 size += int64(256) 49 } 50 // field Description string 51 size += hack.RuntimeAllocSize(int64(len(cached.Description))) 52 // field Name string 53 size += hack.RuntimeAllocSize(int64(len(cached.Name))) 54 // field requestIP vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp 55 size += cached.requestIP.CachedSize(false) 56 // field user vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp 57 size += cached.user.CachedSize(false) 58 // field query vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp 59 size += cached.query.CachedSize(false) 60 // field leadingComment vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp 61 size += cached.leadingComment.CachedSize(false) 62 // field trailingComment vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp 63 size += cached.trailingComment.CachedSize(false) 64 // field plans []vitess.io/vitess/go/vt/vttablet/tabletserver/planbuilder.PlanType 65 { 66 size += hack.RuntimeAllocSize(int64(cap(cached.plans)) * int64(8)) 67 } 68 // field tableNames []string 69 { 70 size += hack.RuntimeAllocSize(int64(cap(cached.tableNames)) * int64(16)) 71 for _, elem := range cached.tableNames { 72 size += hack.RuntimeAllocSize(int64(len(elem))) 73 } 74 } 75 // field bindVarConds []vitess.io/vitess/go/vt/vttablet/tabletserver/rules.BindVarCond 76 { 77 size += hack.RuntimeAllocSize(int64(cap(cached.bindVarConds)) * int64(48)) 78 for _, elem := range cached.bindVarConds { 79 size += elem.CachedSize(false) 80 } 81 } 82 return size 83 } 84 func (cached *Rules) CachedSize(alloc bool) int64 { 85 if cached == nil { 86 return int64(0) 87 } 88 size := int64(0) 89 if alloc { 90 size += int64(24) 91 } 92 // field rules []*vitess.io/vitess/go/vt/vttablet/tabletserver/rules.Rule 93 { 94 size += hack.RuntimeAllocSize(int64(cap(cached.rules)) * int64(8)) 95 for _, elem := range cached.rules { 96 size += elem.CachedSize(true) 97 } 98 } 99 return size 100 } 101 func (cached *bvcre) CachedSize(alloc bool) int64 { 102 if cached == nil { 103 return int64(0) 104 } 105 size := int64(0) 106 if alloc { 107 size += int64(8) 108 } 109 // field re *regexp.Regexp 110 if cached.re != nil { 111 size += hack.RuntimeAllocSize(int64(153)) 112 } 113 return size 114 } 115 func (cached *namedRegexp) CachedSize(alloc bool) int64 { 116 if cached == nil { 117 return int64(0) 118 } 119 size := int64(0) 120 if alloc { 121 size += int64(24) 122 } 123 // field name string 124 size += hack.RuntimeAllocSize(int64(len(cached.name))) 125 // field Regexp *regexp.Regexp 126 if cached.Regexp != nil { 127 size += hack.RuntimeAllocSize(int64(153)) 128 } 129 return size 130 }