DonalEvans commented on a change in pull request #6699:
URL: https://github.com/apache/geode/pull/6699#discussion_r673410063



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/size/SizeableObjectSizer.java
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.size;
+
+/**
+ * A sizer that allows for efficient sizing of objects that implement the 
{@link Sizeable}
+ * interface, and delegates to {@link ReflectionSingleObjectSizer} otherwise.
+ */
+public class SizeableObjectSizer implements SingleObjectSizer {
+
+  private final SingleObjectSizer sizer = new ReflectionSingleObjectSizer();
+
+  @Override
+  public long sizeof(Object object) {

Review comment:
       The `SingleObjectSizer` interface that `SizeableObjectSizer` implements 
returns a long from its `sizeof()` method, so returning an int here would mean 
either breaking the inheritance relationship between the two or changing 
`SingleObjectSizer` to return int instead of long, which will also affect 
`CachingSingleObjectSizer`, `InstrumentationSingleObjectSizer` and 
`ReflectionSingleObjectSizer`, with further knock-on effects that are outside 
the scope of this PR. As a compromise, would it be acceptable to leave the 
return type as long, but call `Coder.narrowLongToInt()` on the returned value 
rather than casting it? This will prevent integer overflow in the size, but 
avoid the need to do refactoring outside the redis module.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to