Skip to content

Commit

Permalink
#157 Log progress of game data processing
Browse files Browse the repository at this point in the history
  • Loading branch information
b0n541 committed Mar 27, 2024
1 parent 16b5da9 commit 1bba1a1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import org.jskat.util.CardList;
import org.jskat.util.GameType;
import org.jskat.util.Player;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
Expand All @@ -22,6 +25,7 @@
*/
public class IssGameExtractor {

private static final Logger LOG = LoggerFactory.getLogger(IssGameExtractor.class);
private final String sourceFileName;

public static void main(final String[] args) throws Exception {
Expand All @@ -36,7 +40,14 @@ public IssGameExtractor(final String sourceFileName) {
private void filterGameDatabase(final Predicate<SkatGameData> predicate, final String targetFileName) throws Exception {

try (final Stream<String> stream = Files.lines(Paths.get(sourceFileName))) {
final AtomicInteger count = new AtomicInteger();
final var filteredGames = stream
.peek(it -> {
final var newCount = count.incrementAndGet();
if (newCount % 100_000 == 0) {
LOG.info("{} games processed", newCount);
}
})
.map(MessageParser::parseGameSummary)
.filter(skatGameData -> skatGameData != null)
.map(SkatGameData::toString)
Expand Down

0 comments on commit 1bba1a1

Please sign in to comment.