Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Fukushima <[email protected]>
  • Loading branch information
gfukushima committed Jan 24, 2025
1 parent 0ca062a commit 7c8bced
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -922,31 +922,32 @@ public boolean pruneOldestBlobSidecars(
final UInt64 lastSlotToPrune,
final int pruneLimit,
final DataArchiveWriter<List<BlobSidecar>> archiveWriter) {
return pruneBlobSidecars(pruneLimit, lastSlotToPrune , archiveWriter, false );
return pruneBlobSidecars(pruneLimit, lastSlotToPrune, archiveWriter, false);
}

@Override
public boolean pruneOldestNonCanonicalBlobSidecars(
final UInt64 lastSlotToPrune,
final int pruneLimit,
final DataArchiveWriter<List<BlobSidecar>> archiveWriter) {
return pruneBlobSidecars(pruneLimit, lastSlotToPrune, archiveWriter, true );

return pruneBlobSidecars(pruneLimit, lastSlotToPrune, archiveWriter, true);
}

private boolean pruneBlobSidecars(
final int pruneLimit,
final UInt64 lastSlotToPrune, final DataArchiveWriter<List<BlobSidecar>> archiveWriter,
final boolean nonCanonicalBlobSidecars) {
final int pruneLimit,
final UInt64 lastSlotToPrune,
final DataArchiveWriter<List<BlobSidecar>> archiveWriter,
final boolean nonCanonicalBlobSidecars) {

int pruned = 0;
Optional<UInt64> earliestBlobSidecarSlot = getEarliestBlobSidecarSlot();
try (final Stream<SlotAndBlockRootAndBlobIndex> prunableBlobKeys =
streamNonCanonicalBlobSidecarKeys(earliestBlobSidecarSlot.orElse(UInt64.ZERO), lastSlotToPrune)) {
streamNonCanonicalBlobSidecarKeys(
earliestBlobSidecarSlot.orElse(UInt64.ZERO), lastSlotToPrune)) {
// Group the BlobSidecars by slot. Potential for higher memory usage
// if it hasn't been pruned in a while
final Map<UInt64, List<SlotAndBlockRootAndBlobIndex>> prunableMap =
prunableBlobKeys.collect(groupingBy(SlotAndBlockRootAndBlobIndex::getSlot));
prunableBlobKeys.collect(groupingBy(SlotAndBlockRootAndBlobIndex::getSlot));

// pruneLimit is the number of slots to prune, not the number of BlobSidecars
final List<UInt64> slots = prunableMap.keySet().stream().sorted().limit(pruneLimit).toList();
Expand All @@ -956,14 +957,14 @@ private boolean pruneBlobSidecars(

// Retrieve the BlobSidecars for archiving.
final List<BlobSidecar> blobSidecars =
keys.stream()
.map(
nonCanonicalBlobSidecars
? this::getNonCanonicalBlobSidecar
: this::getBlobSidecar)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
keys.stream()
.map(
nonCanonicalBlobSidecars
? this::getNonCanonicalBlobSidecar
: this::getBlobSidecar)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();

// Just warn if we failed to find all the BlobSidecars.
if (keys.size() != blobSidecars.size()) {
Expand Down

0 comments on commit 7c8bced

Please sign in to comment.