def innerValToAny()

in s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala [124:177]


  def innerValToAny(innerValLike: InnerValLike, dataType: String): Any = {
    val dType = InnerVal.toInnerDataType(dataType)
    dType match {
      case InnerVal.LONG =>
        innerValLike.value match {
          case b: BigDecimal => b.toLong
          case l: Long => l
          case i: Int => i.toLong
          case f: Float => f.toLong
          case d: Double => d.toLong
          case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
        }
      case InnerVal.INT =>
        innerValLike.value match {
          case b: BigDecimal => b.toInt
          case l: Long => l.toInt
          case i: Int => i
          case f: Float => f.toInt
          case d: Double => d.toInt
          case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
        }
      case InnerVal.SHORT =>
        innerValLike.value match {
          case b: BigDecimal => b.toShort
          case s: Short => s
          case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
        }
      case InnerVal.BYTE =>
        innerValLike.value match {
          case b: BigDecimal => b.toByte
          case b: Byte => b
          case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
        }
      case InnerVal.FLOAT =>
        innerValLike.value match {
          case b: BigDecimal => b.toFloat
          case d: Double => d.toFloat
          case f: Float => f
          case l: Long => l.toFloat
          case i: Int => i.toFloat
          case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
        }
      case InnerVal.DOUBLE =>
        innerValLike.value match {
          case b: BigDecimal => b.toDouble
          case d: Double => d
          case l: Long => l.toDouble
          case i: Int => i.toDouble
          case f: Float => f.toDouble
          case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
        }
      case _ => innerValLike.value
    }
  }