@@ -157,96 +157,111 @@ default boolean eagerEvalSafeInLazy() {
157157 long baseRamBytesUsed ();
158158 }
159159
160- public static final ExpressionEvaluator .Factory CONSTANT_NULL_FACTORY = new ExpressionEvaluator .Factory () {
160+ private record ConstantNullEvaluator (DriverContext context ) implements ExpressionEvaluator {
161+ private static final String NAME = "ConstantNull" ;
162+ private static final long BASE_RAM_BYTES_USED = RamUsageEstimator .shallowSizeOfInstance (ConstantNullEvaluator .class );
163+
161164 @ Override
162- public ExpressionEvaluator get (DriverContext driverContext ) {
163- return new ExpressionEvaluator () {
164- @ Override
165- public Block eval (Page page ) {
166- return driverContext .blockFactory ().newConstantNullBlock (page .getPositionCount ());
167- }
168-
169- @ Override
170- public void close () {}
171-
172- @ Override
173- public String toString () {
174- return CONSTANT_NULL_NAME ;
175- }
176-
177- @ Override
178- public long baseRamBytesUsed () {
179- return 0 ;
180- }
181- };
165+ public Block eval (Page page ) {
166+ return context .blockFactory ().newConstantNullBlock (page .getPositionCount ());
182167 }
183168
169+ @ Override
170+ public void close () {}
171+
184172 @ Override
185173 public String toString () {
186- return CONSTANT_NULL_NAME ;
174+ return NAME ;
187175 }
188- };
189- private static final String CONSTANT_NULL_NAME = "ConstantNull" ;
190176
191- public static final ExpressionEvaluator .Factory CONSTANT_TRUE_FACTORY = new ExpressionEvaluator .Factory () {
192177 @ Override
193- public ExpressionEvaluator get (DriverContext driverContext ) {
194- return new ExpressionEvaluator () {
195- @ Override
196- public Block eval (Page page ) {
197- return driverContext .blockFactory ().newConstantBooleanBlockWith (true , page .getPositionCount ());
198- }
199-
200- @ Override
201- public void close () {}
202-
203- @ Override
204- public String toString () {
205- return CONSTANT_TRUE_NAME ;
206- }
207-
208- @ Override
209- public long baseRamBytesUsed () {
210- return 0 ;
211- }
178+ public long baseRamBytesUsed () {
179+ return BASE_RAM_BYTES_USED ;
180+ }
181+
182+ record Factory () implements ExpressionEvaluator .Factory {
183+ @ Override
184+ public ConstantNullEvaluator get (DriverContext context ) {
185+ return new ConstantNullEvaluator (context );
212186 };
187+
188+ @ Override
189+ public String toString () {
190+ return NAME ;
191+ }
192+ };
193+ }
194+ public static final ExpressionEvaluator .Factory CONSTANT_NULL_FACTORY = new ConstantNullEvaluator .Factory ();
195+
196+ private record ConstantTrueEvaluator (DriverContext context ) implements ExpressionEvaluator {
197+ private static final String NAME = "ConstantTrue" ;
198+ private static final long BASE_RAM_BYTES_USED = RamUsageEstimator .shallowSizeOfInstance (ConstantTrueEvaluator .class );
199+
200+ @ Override
201+ public Block eval (Page page ) {
202+ return context .blockFactory ().newConstantBooleanBlockWith (true , page .getPositionCount ());
213203 }
214204
205+ @ Override
206+ public void close () {}
207+
215208 @ Override
216209 public String toString () {
217- return CONSTANT_TRUE_NAME ;
210+ return NAME ;
218211 }
219- };
220- private static final String CONSTANT_TRUE_NAME = "ConstantTrue" ;
221212
222- public static final ExpressionEvaluator .Factory CONSTANT_FALSE_FACTORY = new ExpressionEvaluator .Factory () {
223213 @ Override
224- public ExpressionEvaluator get (DriverContext driverContext ) {
225- return new ExpressionEvaluator () {
226- @ Override
227- public Block eval (Page page ) {
228- return driverContext .blockFactory ().newConstantBooleanBlockWith (false , page .getPositionCount ());
229- }
230-
231- @ Override
232- public void close () {}
233-
234- @ Override
235- public String toString () {
236- return CONSTANT_FALSE_NAME ;
237- }
238-
239- @ Override
240- public long baseRamBytesUsed () {
241- return 0 ;
242- }
214+ public long baseRamBytesUsed () {
215+ return BASE_RAM_BYTES_USED ;
216+ }
217+
218+ record Factory () implements ExpressionEvaluator .Factory {
219+ @ Override
220+ public ConstantTrueEvaluator get (DriverContext context ) {
221+ return new ConstantTrueEvaluator (context );
243222 };
223+
224+ @ Override
225+ public String toString () {
226+ return NAME ;
227+ }
228+ };
229+ }
230+ public static final ExpressionEvaluator .Factory CONSTANT_TRUE_FACTORY = new ConstantTrueEvaluator .Factory ();
231+
232+ private record ConstantFalseEvaluator (DriverContext context ) implements ExpressionEvaluator {
233+ private static final String NAME = "ConstantFalse" ;
234+ private static final long BASE_RAM_BYTES_USED = RamUsageEstimator .shallowSizeOfInstance (ConstantFalseEvaluator .class );
235+
236+ @ Override
237+ public Block eval (Page page ) {
238+ return context .blockFactory ().newConstantBooleanBlockWith (false , page .getPositionCount ());
244239 }
245240
241+ @ Override
242+ public void close () {}
243+
246244 @ Override
247245 public String toString () {
248- return CONSTANT_FALSE_NAME ;
246+ return NAME ;
249247 }
250- };
251- private static final String CONSTANT_FALSE_NAME = "ConstantFalse" ;
248+
249+ @ Override
250+ public long baseRamBytesUsed () {
251+ return BASE_RAM_BYTES_USED ;
252+ }
253+
254+ record Factory () implements ExpressionEvaluator .Factory {
255+ @ Override
256+ public ConstantFalseEvaluator get (DriverContext context ) {
257+ return new ConstantFalseEvaluator (context );
258+ };
259+
260+ @ Override
261+ public String toString () {
262+ return NAME ;
263+ }
264+ };
265+ }
266+ public static final ExpressionEvaluator .Factory CONSTANT_FALSE_FACTORY = new ConstantFalseEvaluator .Factory ();
252267}
0 commit comments