vitess.io/vitess@v0.16.2/go/sqltypes/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 sqltypes 19 20 import hack "vitess.io/vitess/go/hack" 21 22 func (cached *Result) CachedSize(alloc bool) int64 { 23 if cached == nil { 24 return int64(0) 25 } 26 size := int64(0) 27 if alloc { 28 size += int64(112) 29 } 30 // field Fields []*vitess.io/vitess/go/vt/proto/query.Field 31 { 32 size += hack.RuntimeAllocSize(int64(cap(cached.Fields)) * int64(8)) 33 for _, elem := range cached.Fields { 34 size += elem.CachedSize(true) 35 } 36 } 37 // field Rows [][]vitess.io/vitess/go/sqltypes.Value 38 { 39 size += hack.RuntimeAllocSize(int64(cap(cached.Rows)) * int64(24)) 40 for _, elem := range cached.Rows { 41 { 42 size += hack.RuntimeAllocSize(int64(cap(elem)) * int64(32)) 43 for _, elem := range elem { 44 size += elem.CachedSize(false) 45 } 46 } 47 } 48 } 49 // field SessionStateChanges string 50 size += hack.RuntimeAllocSize(int64(len(cached.SessionStateChanges))) 51 // field Info string 52 size += hack.RuntimeAllocSize(int64(len(cached.Info))) 53 return size 54 } 55 func (cached *Value) CachedSize(alloc bool) int64 { 56 if cached == nil { 57 return int64(0) 58 } 59 size := int64(0) 60 if alloc { 61 size += int64(32) 62 } 63 // field val []byte 64 { 65 size += hack.RuntimeAllocSize(int64(cap(cached.val))) 66 } 67 return size 68 }