@@ -63,10 +63,6 @@ use shape_inference::{
6363 Shape ,
6464 ShapeEnum ,
6565} ;
66- use usage_tracking:: {
67- round_up,
68- KB ,
69- } ;
7066
7167#[ cfg( any( test, feature = "testing" ) ) ]
7268use crate :: IndexModel ;
@@ -83,17 +79,14 @@ use crate::{
8379pub struct TableSummary {
8480 inferred_type : CountedShape < ProdConfigWithOptionalFields > ,
8581 total_size : i64 ,
86- // Used for metered billing, we charge for database storage rounded up to
87- // the nearest KB per document
88- total_size_rounded : i64 ,
8982}
9083
9184impl fmt:: Display for TableSummary {
9285 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
9386 write ! (
9487 f,
95- "TableSummary {{ inferred_type: {}, total_size: {}, total_size_rounded: {} }}" ,
96- self . inferred_type, self . total_size, self . total_size_rounded
88+ "TableSummary {{ inferred_type: {}, total_size: {} }}" ,
89+ self . inferred_type, self . total_size
9790 )
9891 }
9992}
@@ -103,22 +96,17 @@ impl TableSummary {
10396 Self {
10497 inferred_type : Shape :: empty ( ) ,
10598 total_size : 0 ,
106- total_size_rounded : 0 ,
10799 }
108100 }
109101
110102 pub fn is_empty ( & self ) -> bool {
111- self . inferred_type . is_empty ( ) && self . total_size == 0 && self . total_size_rounded == 0
103+ self . inferred_type . is_empty ( ) && self . total_size == 0
112104 }
113105
114106 pub fn total_size ( & self ) -> usize {
115107 self . total_size as usize
116108 }
117109
118- pub fn total_size_rounded ( & self ) -> i64 {
119- self . total_size_rounded
120- }
121-
122110 pub fn num_values ( & self ) -> usize {
123111 * self . inferred_type . num_values ( ) as usize
124112 }
@@ -129,27 +117,18 @@ impl TableSummary {
129117
130118 pub fn insert ( & self , object : & ConvexObject ) -> Self {
131119 let total_size = self . total_size + object. size ( ) as i64 ;
132- let total_size_rounded =
133- self . total_size_rounded + round_up ( object. size ( ) as u64 , KB ) as i64 ;
134120 Self {
135121 inferred_type : self . inferred_type . insert ( object) ,
136122 total_size,
137- total_size_rounded,
138123 }
139124 }
140125
141126 pub fn remove ( & self , object : & ConvexObject ) -> anyhow:: Result < Self > {
142127 let size = object. size ( ) as i64 ;
143- let size_rounded = round_up ( object. size ( ) as u64 , KB ) as i64 ;
144128 anyhow:: ensure!( self . total_size >= size, "Negative size due to {object}" ) ;
145- anyhow:: ensure!(
146- self . total_size_rounded >= size_rounded,
147- "Negative size due to {object}"
148- ) ;
149129 Ok ( Self {
150130 inferred_type : self . inferred_type . remove ( object) ?,
151131 total_size : self . total_size - size,
152- total_size_rounded : self . total_size_rounded - size_rounded,
153132 } )
154133 }
155134
@@ -166,7 +145,6 @@ impl From<&TableSummary> for JsonValue {
166145 fn from ( summary : & TableSummary ) -> Self {
167146 json ! ( {
168147 "totalSize" : JsonInteger :: encode( summary. total_size) ,
169- "totalSizeRounded" : JsonInteger :: encode( summary. total_size_rounded) ,
170148 "inferredTypeWithOptionalFields" : JsonValue :: from( & summary. inferred_type)
171149 } )
172150 }
@@ -183,19 +161,13 @@ impl TryFrom<JsonValue> for TableSummary {
183161 _ => anyhow:: bail!( "Invalid totalSize" ) ,
184162 } ;
185163 anyhow:: ensure!( total_size >= 0 ) ;
186- let total_size_rounded = match v. remove ( "totalSizeRounded" ) {
187- Some ( JsonValue :: String ( s) ) => JsonInteger :: decode ( s) ?,
188- _ => anyhow:: bail!( "Invalid totalSizeRounded" ) ,
189- } ;
190- anyhow:: ensure!( total_size_rounded >= 0 ) ;
191164 let inferred_type = match v. remove ( "inferredTypeWithOptionalFields" ) {
192165 Some ( v) => CountedShape :: < ProdConfigWithOptionalFields > :: try_from ( v) ?,
193166 None => anyhow:: bail!( "Missing field inferredTypeWithOptionalFields" ) ,
194167 } ;
195168 Ok ( TableSummary {
196169 inferred_type,
197170 total_size,
198- total_size_rounded,
199171 } )
200172 } ,
201173 _ => anyhow:: bail!( "Wrong type of json value for TableSummaryJson" ) ,
0 commit comments