clintropolis commented on code in PR #15371:
URL: https://github.com/apache/druid/pull/15371#discussion_r1409864208


##########
processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java:
##########
@@ -19,75 +19,50 @@
 
 package org.apache.druid.segment;
 
+import org.apache.druid.error.DruidException;
+
 /**
- * This class is convenient for implementation of "object-sourcing" {@link 
ColumnValueSelector}s, it provides default
- * implementations for all {@link ColumnValueSelector}'s methods except {@link 
#getObject()} and {@link
- * #classOfObject()}.
- *
- * This class should appear ONLY in "extends" clause or anonymous class 
creation, but NOT in "user" code, where
- * {@link BaseObjectColumnValueSelector} must be used instead.
+ * Object based column selector.
  *
- * This is a class rather than an interface unlike {@link LongColumnSelector}, 
{@link FloatColumnSelector} and {@link
- * DoubleColumnSelector} solely in order to make {@link #isNull()} method 
final.
+ * This abstract class provides a {@link ColumnValueSelector} based on the 
methods of {@link BaseObjectColumnValueSelector}.
  */
 public abstract class ObjectColumnSelector<T> implements ColumnValueSelector<T>
 {
-  /**
-   * @deprecated This method is marked as deprecated in ObjectColumnSelector 
to minimize the probability of accidental
-   * calling. "Polymorphism" of ObjectColumnSelector should be used only when 
operating on {@link ColumnValueSelector}
-   * objects.
-   */
-  @Deprecated
+  private static final String COLUMN_IS_NULL_ERROR_MESSAGE = "Invalid usage 
pattern: method returning primitive called - but the column is null";
+
   @Override
-  public float getFloat()
+  public final float getFloat()
   {
     T value = getObject();
     if (value == null) {
-      return 0;
+      throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE);
     }
     return ((Number) value).floatValue();
   }
 
-  /**
-   * @deprecated This method is marked as deprecated in ObjectColumnSelector 
to minimize the probability of accidental
-   * calling. "Polymorphism" of ObjectColumnSelector should be used only when 
operating on {@link ColumnValueSelector}
-   * objects.
-   */
-  @Deprecated
   @Override
-  public double getDouble()
+  public final double getDouble()
   {
     T value = getObject();
     if (value == null) {
-      return 0;
+      throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE);
     }
     return ((Number) value).doubleValue();
   }
 
-  /**
-   * @deprecated This method is marked as deprecated in ObjectColumnSelector 
to minimize the probability of accidental
-   * calling. "Polymorphism" of ObjectColumnSelector should be used only when 
operating on {@link ColumnValueSelector}
-   * objects.
-   */
-  @Deprecated
   @Override
-  public long getLong()
+  public final long getLong()
   {
     T value = getObject();
     if (value == null) {
-      return 0;
+      throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE);
     }
     return ((Number) value).longValue();
   }
 
-  /**
-   * @deprecated This method is marked as deprecated in ObjectColumnSelector 
since it always returns false.
-   * There is no need to call this method.
-   */
-  @Deprecated
   @Override
   public final boolean isNull()
   {
-    return false;
+    return getObject() == null;

Review Comment:
   while I guess this is harmless, nothing calling `getObject` should ever be 
using `isNull`, instead they should be checking that `getObject` returns null
   
   if this change is fixing something then whatever it is fixing is probably 
wrong



##########
processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java:
##########
@@ -19,75 +19,50 @@
 
 package org.apache.druid.segment;
 
+import org.apache.druid.error.DruidException;
+
 /**
- * This class is convenient for implementation of "object-sourcing" {@link 
ColumnValueSelector}s, it provides default
- * implementations for all {@link ColumnValueSelector}'s methods except {@link 
#getObject()} and {@link
- * #classOfObject()}.
- *
- * This class should appear ONLY in "extends" clause or anonymous class 
creation, but NOT in "user" code, where
- * {@link BaseObjectColumnValueSelector} must be used instead.
+ * Object based column selector.
  *
- * This is a class rather than an interface unlike {@link LongColumnSelector}, 
{@link FloatColumnSelector} and {@link
- * DoubleColumnSelector} solely in order to make {@link #isNull()} method 
final.
+ * This abstract class provides a {@link ColumnValueSelector} based on the 
methods of {@link BaseObjectColumnValueSelector}.
  */
 public abstract class ObjectColumnSelector<T> implements ColumnValueSelector<T>
 {
-  /**
-   * @deprecated This method is marked as deprecated in ObjectColumnSelector 
to minimize the probability of accidental
-   * calling. "Polymorphism" of ObjectColumnSelector should be used only when 
operating on {@link ColumnValueSelector}
-   * objects.
-   */
-  @Deprecated
+  private static final String COLUMN_IS_NULL_ERROR_MESSAGE = "Invalid usage 
pattern: method returning primitive called - but the column is null";
+
   @Override
-  public float getFloat()
+  public final float getFloat()
   {
     T value = getObject();
     if (value == null) {
-      return 0;
+      throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE);
     }
     return ((Number) value).floatValue();
   }
 
-  /**
-   * @deprecated This method is marked as deprecated in ObjectColumnSelector 
to minimize the probability of accidental
-   * calling. "Polymorphism" of ObjectColumnSelector should be used only when 
operating on {@link ColumnValueSelector}
-   * objects.
-   */
-  @Deprecated

Review Comment:
   i think the main reason it was marked deprecated is so that intellij makes 
it pretty obvious if you're accidentally calling it on an object selector, its 
not really possible to remove it without reworking the column selector 
interfaces to split them up



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to