环境

  • 软件
    • Java JDK for Java 8 or Java 11
    • git
    • an IDE (IntelliJ recommended)
  • 复制并构建https://github.com/ververica/flink-training
    • 跟随README指示
    • 代码包含Java和scala2个版本。默认不启用scala,如果需要使用的话,在gradle.properties中设置
      • org.gradle.project.enable_scala = true
  • 将项目导入你自己的IDE…

验证项目

  • 运行一个测试
    • org.apache.flink.training.exercises.ridecleansing.RideCleansingIntegrationTest
  • 运行一个例子
    • org.apache.flink.training.examples.ridecount.RideCountExample

数据集

TaxiRide出租车行程

  1. rideId : Long // a unique id for each ride
  2. taxiId : Long // a unique id for each taxi
  3. driverId : Long // a unique id for each driver
  4. isStart : Boolean // TRUE for ride start events,
  5. // FALSE for ride end events
  6. eventTime : Instant // timestamp
  7. startLon : Float // the longitude of the ride start location
  8. startLat : Float // the latitude of the ride start location
  9. endLon : Float // the longitude of the ride end location
  10. endLat : Float // the latitude of the ride end location
  11. passengerCnt : Short // number of passengers on the ride

每一趟出租车行程包含2个event。一个开始事件,一个结束事件,通过isStart来区分。

TaxiFare出租车计费

  1. rideId : Long // a unique id for each ride
  2. taxiId : Long // a unique id for each taxi
  3. driverId : Long // a unique id for each driver
  4. startTime : Instant // the start time of a ride
  5. paymentType : String // CASH or CARD (for cash or card payments)
  6. tip : Float // tip for this ride
  7. tolls : Float // tolls for this ride
  8. totalFare : Float // total fare collected

每个TaxiRide事件都对应TaxiFare事件,表示这趟行程的费用。2个事件的rideId,taxiId,driverId保持一致。需要说明的是,支付通常发生在行程结束时,但这里我们给的时间戳是这趟行程的开始时间。

tests

● 所有的project中的tests都会测试Exercise类,如果exercise抛出MissingSolutionException异常,那么程序会吞掉异常,将tests应用到对应的solution类上。也就是说,工程拿过来,即使不填代码也是可以直接test跑起来的。
● 我们重点分析Java测试,scala测试暂时不做过多分析,有兴趣的自行查看