- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 XMLIO.scala
中定义了自定义输入和输出格式:
import scala.xml.Node
import org.apache.hadoop.lib.input.FileInputFormat
import org.apache.hadoop.lib.output.FileOutputFormat
import org.apache.hadoop.mapreduce.{ RecordReader, RecordWriter }
// ...
object XMLIO {
class XMLInputFormat extends FileInputFormat[LongWritable, Node] { /*...*/ }
class XMLRecordReader extends RecordReader[LongWritable, Node] { /*...*/ }
class XMLOutputFormat extends FileOutputFormat[LongWritable, Node] { /*...*/ }
class XMLRecordWriter extends RecordWriter[LongWritable, Node] { /*...*/ }
}
Example.scala
中定义的工作:
import XMLIO._
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.mapreduce.Job
object Example {
@throws(classOf[Exception])
def main( args : Array[String] ) {
val job = new Job(new Configuration(), "")
job setInputFormatClass classOf[XMLInputFormat]
}
}
[ERROR] /path/to/Example.scala:8: error: type mismatch;
[INFO] found : java.lang.Class[XMLInputFormat](classOf[XMLInputFormat])
[INFO] required: java.lang.Class[_ <: org.apache.hadoop.mapreduce.InputFormat]
[INFO] job setInputFormatClass classOf[XMLInputFormat]
[INFO] ^
XMLInputFormat
,这对我来说似乎很奇怪是
FileInputFormat
的子类,它是
InputFormat
的子类.
XMLInputFormat
的实例在我设置输入格式类之前,没有编译器错误。也就是说,以下编译正常:
import XMLIO._
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.mapreduce.Job
object Example {
@throws(classOf[Exception])
def main( args : Array[String] ) {
val x = new XMLInputFormat()
val job = new Job(new Configuration(), "")
job setInputFormatClass classOf[XMLInputFormat]
}
}
最佳答案
看起来这是 scala 2.9.0(这是我使用的)的错误。当我升级到 Scala 2.9.1 时,问题就消失了。
关于Scala/Hadoop : Compiler error when using classOf[CustomInputFormat] unless instance of CustomInputFormat exists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10260226/
如何声明expectedException,才能只传递Exception和子类?目前我正在使用 expectedException: Any。 详细信息。 我有一个像这样调用的测试实用程序方法, as
我正在尝试使用 scala/java 创建一个用于对象更新的通用方法,但我无法获取类型参数的类。 这是我的代码: object WorkUnitController extends Controlle
我有以下代码: class ServletSpec extends Specification { def createServlet[T <: HttpServlet](clazz: Cla
我需要在用 Java 编写的类上调用 classOf,如下所示: public class Order {...} 其中Item如下所示 public class Item {...} 然后我需要将
我正在为 ScalaTest 开发一个客户可读的 DSL。目前我可以写 feature("Admin Login") { scenario("Correct username and passwo
我想知道如何在 Scala 中获取对象类型的类对象。好吧,由于对象的双重含义,这是满嘴的。所以这里有一个会失败的例子: object Main { private [this] val TAG
让我举个例子来解释我想做什么(或者至少知道这是否可行): 在 Clang 中,让我们使用一些基本的 ValueDecl .正如您在提供的链接中所见,此 ValueDecl 可以: 做一个简单的Valu
我正在尝试将JUnit从4.10升级到5.3.1一个Scala项目。该项目正在使用Scalatest。我想知道现在应该用以下代码替换什么: @RunWith(classOf[JUnitRunner])
Here ,我想知道如何实现Collection#toArray(T[] array)适本地。我最生气的是array.getClass().getComponentType()类型为Class而不是C
我有这个代码 "123".getClass.asInstanceOf[Class[String]] "123".getClass.asInstanceOf[classOf[String]]//comp
用Java编写简单的Map Reduce程序时,下面的行可以正常工作。 job.setOutputFormatClass(TextOutputFormat.class) 但是Scala中的同一件
在我的示例中,我希望能够返回类 Of[frame] 而不是我得到一个错误未找到:输入 frame。 trait User extends VertexFrame { ... } object Us
我在scala中遇到了一些非常奇怪的行为。 我编写了一个通用方法,该方法将容易出错的代码和“有效异常”列表作为参数,并且应该执行该代码,同时在抛出“有效异常”时重试该代码。 该方法很好用,我在几个地方
我有一个来自 Java 的接口(interface) public class IJava { ... public java.lang.Class getType(); ... }
我在 XMLIO.scala 中定义了自定义输入和输出格式: import scala.xml.Node import org.apache.hadoop.lib.input.FileInputFor
我写了一小段测试代码,正在用 IntelliJ IDEA 12 CE 编译它 import com.twitter.common.zookeeper.ZooKeeperClient import or
我是一名优秀的程序员,十分优秀!