Skip to content

Commit

Permalink
Added TypeTag field to all NativeTypes
Browse files Browse the repository at this point in the history
Signed-off-by: Cheng Lian <lian.cs.zju@gmail.com>
  • Loading branch information
liancheng committed Mar 22, 2014
1 parent acc5c48 commit 34f3c19
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package org.apache.spark.sql
package catalyst
package types

import expressions.Expression
import scala.reflect.runtime.universe.{typeTag, TypeTag}

import org.apache.spark.sql.catalyst.expressions.Expression

abstract class DataType {
/** Matches any expression that evaluates to this DataType */
Expand All @@ -33,18 +35,21 @@ case object NullType extends DataType

abstract class NativeType extends DataType {
type JvmType
@transient val tag: TypeTag[JvmType]
val ordering: Ordering[JvmType]
}

case object StringType extends NativeType {
type JvmType = String
@transient lazy val tag = typeTag[JvmType]
val ordering = implicitly[Ordering[JvmType]]
}
case object BinaryType extends DataType {
type JvmType = Array[Byte]
}
case object BooleanType extends NativeType {
type JvmType = Boolean
@transient lazy val tag = typeTag[JvmType]
val ordering = implicitly[Ordering[JvmType]]
}

Expand All @@ -71,27 +76,31 @@ abstract class IntegralType extends NumericType {

case object LongType extends IntegralType {
type JvmType = Long
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[Long]]
val integral = implicitly[Integral[Long]]
val ordering = implicitly[Ordering[JvmType]]
}

case object IntegerType extends IntegralType {
type JvmType = Int
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[Int]]
val integral = implicitly[Integral[Int]]
val ordering = implicitly[Ordering[JvmType]]
}

case object ShortType extends IntegralType {
type JvmType = Short
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[Short]]
val integral = implicitly[Integral[Short]]
val ordering = implicitly[Ordering[JvmType]]
}

case object ByteType extends IntegralType {
type JvmType = Byte
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[Byte]]
val integral = implicitly[Integral[Byte]]
val ordering = implicitly[Ordering[JvmType]]
Expand All @@ -110,20 +119,23 @@ abstract class FractionalType extends NumericType {

case object DecimalType extends FractionalType {
type JvmType = BigDecimal
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[BigDecimal]]
val fractional = implicitly[Fractional[BigDecimal]]
val ordering = implicitly[Ordering[JvmType]]
}

case object DoubleType extends FractionalType {
type JvmType = Double
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[Double]]
val fractional = implicitly[Fractional[Double]]
val ordering = implicitly[Ordering[JvmType]]
}

case object FloatType extends FractionalType {
type JvmType = Float
@transient lazy val tag = typeTag[JvmType]
val numeric = implicitly[Numeric[Float]]
val fractional = implicitly[Fractional[Float]]
val ordering = implicitly[Ordering[JvmType]]
Expand Down

0 comments on commit 34f3c19

Please sign in to comment.