Skip to content

Commit

Permalink
Also track the number of removed mappables
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Steinbeck committed Dec 16, 2023
1 parent 8bc767d commit b913145
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,18 @@ public void add(@NonNull final Mapping.Result<T> result)
throw new UncheckedIOException(e);
}
// Update `lifespans` and `mappables`.
final int removed = mappables.size() // those active in the last call
- toUpdate.size(); // those updated in this call
toAdd.forEach(ma -> lifespans.add(ma.getLifespan()));
mappables.clear();
toAdd.forEach(ma -> mappables.put(ma.getMappable(), ma.getLifespan()));
toUpdate.forEach(mu -> mappables.put(mu.getTo(), mu.getLifespan()));
// Write lifespan info file.
try {
if (first) {
final String header = String.join(DELIMITER, "ordinal",
"total", "active", "updated", "added") + "\n";
final String header = String.join(DELIMITER,
"ordinal", "total", "active", "updated", "added",
"removed") + "\n";
Files.writeString(directory.resolve(LIFESPAN_INFO_FILE),
header, CHARSET,
StandardOpenOption.CREATE,
Expand All @@ -189,17 +192,18 @@ public void add(@NonNull final Mapping.Result<T> result)
String.valueOf(lifespans.size()),
String.valueOf(mappables.size()),
String.valueOf(toUpdate.size()),
String.valueOf(toAdd.size())) + "\n";
String.valueOf(toAdd.size()),
String.valueOf(removed)) + "\n";
Files.writeString(directory.resolve(LIFESPAN_INFO_FILE),
row, CHARSET,
StandardOpenOption.APPEND);
first = false;
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
log.info("Tracking {} lifespans (active: {}, updated: {}, added: {})",
log.info("Tracking {} lifespans (active: {}, updated: {}, added: {}, removed: {})",
lifespans.size(), mappables.size(), toUpdate.size(),
toAdd.size());
toAdd.size(), removed);
}

/**
Expand Down

0 comments on commit b913145

Please sign in to comment.