in product-mixer/component-library/src/main/scala/com/twitter/product_mixer/component_library/selector/sorter/FeatureValueSorter.scala [217:247]
private[sorter] def featureOptionalValueSortDefaultValue[FeatureValue: Ordering](
feature: Feature[_, Option[FeatureValue]],
sortOrder: SortOrder
)(
implicit typeTag: TypeTag[FeatureValue]
): FeatureValue = {
val defaultValue = sortOrder match {
case Descending =>
typeOf[Option[FeatureValue]] match {
case t if t <:< typeOf[Option[Short]] => Short.MinValue
case t if t <:< typeOf[Option[Int]] => Int.MinValue
case t if t <:< typeOf[Option[Long]] => Long.MinValue
case t if t <:< typeOf[Option[Double]] => Double.MinValue
case t if t <:< typeOf[Option[Float]] => Float.MinValue
case _ =>
throw new UnsupportedOperationException(s"Default value not supported for $feature")
}
case Ascending =>
typeOf[Option[FeatureValue]] match {
case t if t <:< typeOf[Option[Short]] => Short.MaxValue
case t if t <:< typeOf[Option[Int]] => Int.MaxValue
case t if t <:< typeOf[Option[Long]] => Long.MaxValue
case t if t <:< typeOf[Option[Double]] => Double.MaxValue
case t if t <:< typeOf[Option[Float]] => Float.MaxValue
case _ =>
throw new UnsupportedOperationException(s"Default value not supported for $feature")
}
}
defaultValue.asInstanceOf[FeatureValue]
}