Created
November 21, 2019 12:30
-
-
Save Igosuki/ab5d77852c025eac4586fbd021bf0383 to your computer and use it in GitHub Desktop.
How not to code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for { | |
app <- distinctBundles | |
day <- dateRange(inputStart, inputEnd) | |
hour <- (0 to 23) | |
path = buildPath(inputPath, hour, day, app) | |
} yield (path, fileSystem.isDirectory(new Path(path))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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