2015-04-09 8 views
10

Mam kłopoty przy użyciu Apache Flink Scala APIFlink Scala API „nie mało argumentów”

Na przykład, nawet gdy biorę przykłady z oficjalnej dokumentacji, kompilator Scala daje mi mnóstwo błędów kompilacji.

Kod:

object TestFlink { 

    def main(args: Array[String]) { 
    val env = ExecutionEnvironment.getExecutionEnvironment 
    val text = env.fromElements(
     "Who's there?", 
     "I think I hear them. Stand, ho! Who's there?") 

    val counts = text.flatMap { _.toLowerCase.split("\\W+") filter { _.nonEmpty } } 
     .map { (_, 1) } 
     .groupBy(0) 
     .sum(1) 

    counts.print() 

    env.execute("Scala WordCount Example") 
    } 
} 

Scala IDE wyprowadza następujące dla linii val text = env.fromElements

Multiple markers at this line 
    - not enough arguments for method fromElements: (implicit evidence$14: scala.reflect.ClassTag[String], implicit evidence$15: 
    org.apache.flink.api.common.typeinfo.TypeInformation[String])org.apache.flink.api.scala.DataSet[String]. Unspecified value parameter evidence$15. 
    - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String] 
    - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String] 
    - not enough arguments for method fromElements: (implicit evidence$14: scala.reflect.ClassTag[String], implicit evidence$15: 
    org.apache.flink.api.common.typeinfo.TypeInformation[String])org.apache.flink.api.scala.DataSet[String]. Unspecified value parameter evidence$15. 

To nie tylko fromElements metoda: nawet jeśli czytam z pliku, a następnie spróbuj zrobić coś tak prostego jako ds.map(r => r), otrzymuję coś bardzo podobnego:

Multiple markers at this line 
    - not enough arguments for method map: (implicit evidence$4: org.apache.flink.api.common.typeinfo.TypeInformation[K], implicit 
    evidence$5: scala.reflect.ClassTag[K])org.apache.flink.api.scala.DataSet[K]. Unspecified value parameters evidence$4, evidence$5. 
    - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[K] 
    - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[K] 
    - not enough arguments for method map: (implicit evidence$4: org.apache.flink.api.common.typeinfo.TypeInformation[K], implicit 
    evidence$5: scala.reflect.ClassTag[K])org.apache.flink.api.scala.DataSet[K]. Unspecified value parameters evidence$4, evidence$5. 

Próbowałem dwóch wersji Flink: 0.8.1 od Maven Central i najbardziej świeżego z repozytorium github.

Używam Windows 7, Scala 2.10.4 JDK 1.7.0_25 wersji Scala IDE jest 3.0.3-20140327-1716-Typesafe na szczycie Eclipse 4.3.0

Co robię źle ?

Odpowiedz

19

Trzeba dodać następujące import do kodu:

import org.apache.flink.api.scala._ 

Wtedy przykład działa.

+1

Dzięki Robert. Chociaż rozwiązuje on opisane problemy, nadal mam inne problemy z ogólnymi parametrami. Czy mógłbyś rzucić okiem na kontynuację tutaj http://stackoverflow.com/questions/29542214 –

+0

Przekazałem pytanie ...;) –

Powiązane problemy