Skip to content

Instantly share code, notes, and snippets.

@Igosuki
Created November 21, 2019 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Igosuki/ab5d77852c025eac4586fbd021bf0383 to your computer and use it in GitHub Desktop.
Save Igosuki/ab5d77852c025eac4586fbd021bf0383 to your computer and use it in GitHub Desktop.
How not to code
for {
app <- distinctBundles
day <- dateRange(inputStart, inputEnd)
hour <- (0 to 23)
path = buildPath(inputPath, hour, day, app)
} yield (path, fileSystem.isDirectory(new Path(path)))
// app, day, hour
val appsAndDates: fs2.Stream[fs2.Pure, (AppAndOs, LocalDate)] = fs2.Stream
.emits(distinctBundles)
.flatMap(
app =>
fs2.Stream
.emits(dateRange(inputStart, inputEnd))
.map((app, _))
)
appsAndDates
.flatMap {
case (app, day) =>
fs2.Stream
.emits((0 to 23))
.map(buildPath(inputPath, _, day, app))
}
.map(ensureTrailingSlash)
.covary[IO]
.parEvalMapUnordered(10)((path: String) => IO.delay(fileSystem.isDirectory(new Path(path))).map((path, _)))
.collect { case (path, true) => path }
.compile
.toList
.unsafeRunSync()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment