scala.reflect.runtime.universe.TypeTag Scala Examples

The following examples show how to use scala.reflect.runtime.universe.TypeTag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: HBaseBytesType.scala    From Backup-Repo   with Apache License 2.0 5 votes vote down vote up
package org.apache.spark.sql.hbase.types

import org.apache.spark.sql.catalyst.ScalaReflectionLock
import org.apache.spark.sql.hbase.HBaseRawType
import org.apache.spark.sql.types._

import scala.reflect.runtime.universe.typeTag

 {
  override def defaultSize: Int = 4096
  private[sql] type InternalType = HBaseRawType
  @transient private[sql] lazy val tag =  ScalaReflectionLock.synchronized {typeTag[InternalType]}
  private[sql] val ordering = new Ordering[InternalType] {
    def compare(x: Array[Byte], y: Array[Byte]): Int = {
      for (i <- x.indices if i < y.length) {
        val a: Int = x(i) & 0xff
        val b: Int = y(i) & 0xff
        val res = a - b
        if (res != 0) return res
      }
      x.length - y.length
    }
  }
 
  private[spark] override def asNullable = this
} 
Example 2
Source File: TypeUtilsSpec.scala    From seahorse   with Apache License 2.0 5 votes vote down vote up
package ai.deepsense.deeplang


import scala.reflect.runtime.universe.typeTag

class TypeUtilsSpec extends UnitSpec {

  import TypeUtilsSpec._

  "TypeUtils.describeType" should {
    "describe class" in {
      TypeUtils.describeType(typeTag[A].tpe) shouldBe Seq(describedA)
    }
    "describe trait" in {
      TypeUtils.describeType(typeTag[B].tpe) shouldBe Seq(describedB)
    }
    "describe complex type" in {
      TypeUtils.describeType(typeTag[A with B].tpe) shouldBe Seq(describedA, describedB)
    }
    "describe parametrized type" in {
      TypeUtils.describeType(typeTag[C[A]].tpe) shouldBe Seq(describedC)
    }
    "describe complex parametrized type" in {
      TypeUtils.describeType(typeTag[C[A] with B].tpe) shouldBe Seq(describedC, describedB)
    }
  }
}

object TypeUtilsSpec {
  class A
  trait B
  class C[T]

  val describedA = "ai.deepsense.deeplang.TypeUtilsSpec.A"
  val describedB = "ai.deepsense.deeplang.TypeUtilsSpec.B"
  val describedC = "ai.deepsense.deeplang.TypeUtilsSpec.C"

} 
Example 3
Source File: HBaseBytesType.scala    From Heracles   with Apache License 2.0 5 votes vote down vote up
package org.apache.spark.sql.hbase.types

import org.apache.spark.sql.catalyst.ScalaReflectionLock
import org.apache.spark.sql.hbase.HBaseRawType
import org.apache.spark.sql.types._

import scala.reflect.runtime.universe.typeTag

 {
  override def defaultSize: Int = 4096
  private[sql] type InternalType = HBaseRawType
  @transient private[sql] lazy val tag =  ScalaReflectionLock.synchronized {typeTag[InternalType]}
  private[sql] val ordering = new Ordering[InternalType] {
    def compare(x: Array[Byte], y: Array[Byte]): Int = {
      for (i <- x.indices if i < y.length) {
        val a: Int = x(i) & 0xff
        val b: Int = y(i) & 0xff
        val res = a - b
        if (res != 0) return res
      }
      x.length - y.length
    }
  }
 
  private[spark] override def asNullable = this
} 
Example 4
Source File: HBaseBytesType.scala    From Spark-SQL-on-HBase   with Apache License 2.0 5 votes vote down vote up
package org.apache.spark.sql.hbase.types

import org.apache.spark.sql.catalyst.ScalaReflectionLock
import org.apache.spark.sql.hbase.HBaseRawType
import org.apache.spark.sql.types._

import scala.reflect.runtime.universe.typeTag

 {
  override def defaultSize: Int = 4096
  private[sql] type InternalType = HBaseRawType
  @transient private[sql] lazy val tag =  ScalaReflectionLock.synchronized {typeTag[InternalType]}
  private[sql] val ordering = new Ordering[InternalType] {
    def compare(x: Array[Byte], y: Array[Byte]): Int = {
      for (i <- x.indices if i < y.length) {
        val a: Int = x(i) & 0xff
        val b: Int = y(i) & 0xff
        val res = a - b
        if (res != 0) return res
      }
      x.length - y.length
    }
  }
 
  private[spark] override def asNullable = this
} 
Example 5
Source File: TypeUtilsSpec.scala    From seahorse-workflow-executor   with Apache License 2.0 5 votes vote down vote up
package io.deepsense.deeplang


import scala.reflect.runtime.universe.typeTag

class TypeUtilsSpec extends UnitSpec {

  import TypeUtilsSpec._

  "TypeUtils.describeType" should {
    "describe class" in {
      TypeUtils.describeType(typeTag[A].tpe) shouldBe Seq(describedA)
    }
    "describe trait" in {
      TypeUtils.describeType(typeTag[B].tpe) shouldBe Seq(describedB)
    }
    "describe complex type" in {
      TypeUtils.describeType(typeTag[A with B].tpe) shouldBe Seq(describedA, describedB)
    }
    "describe parametrized type" in {
      TypeUtils.describeType(typeTag[C[A]].tpe) shouldBe Seq(describedC)
    }
    "describe complex parametrized type" in {
      TypeUtils.describeType(typeTag[C[A] with B].tpe) shouldBe Seq(describedC, describedB)
    }
  }
}

object TypeUtilsSpec {
  class A
  trait B
  class C[T]

  val describedA = "io.deepsense.deeplang.TypeUtilsSpec.A"
  val describedB = "io.deepsense.deeplang.TypeUtilsSpec.B"
  val describedC = "io.deepsense.deeplang.TypeUtilsSpec.C"

}