有谁知道在创建模式时如何比较烫伤的连续记录。我正在查看教程 6,并假设如果记录 #2 中的数据大于记录 #1(对于所有记录),我想打印此人的年龄
例如:
R1: John 30
R2: Kim 55
R3: Mark 20
if Rn.age > R(n-1).age the output ... which will result to R2: Kim 55
编辑:查看代码我刚刚意识到它是一个 Scala 枚举,所以我的问题是如何比较 scala 枚举中的记录?
class Tutorial6(args : Args) extends Job(args) {
/** When a data set has a large number of fields, and we want to specify those fields conveniently
in code, we can use, for example, a Tuple of Symbols (as most of the other tutorials show), or a List of Symbols.
Note that Tuples can only be used if the number of fields is at most 22, since Scala Tuples cannot have more
than 22 elements. Another alternative is to use Enumerations, which we show here **/
object Schema extends Enumeration {
val first, last, phone, age, country = Value // arbitrary number of fields
}
import Schema._
Csv("tutorial/data/phones.txt", separator = " ", fields = Schema)
.read
.project(first,age)
.write(Tsv("tutorial/data/output6.tsv"))
}