Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Dec 11, 2024
1 parent 369a372 commit 19deaac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,18 @@ public void maybeFetchRegions(
ActionListener.releaseAfter(listener, () -> regionsToFetch.forEach(AbstractRefCounted::decRef))
)
) {
final List<Tuple<CacheFileRegion<KeyType>, RegionGaps>> gaps = new ArrayList<>();
final List<Tuple<CacheFileRegion<KeyType>, RegionGaps>> gaps = new ArrayList<>(regionsToFetch.size());
for (CacheFileRegion<KeyType> toFetch : regionsToFetch) {
ByteRange regionRange = ByteRange.of(0, computeCacheFileRegionSize(blobLength, toFetch.regionKey.region));
int region = toFetch.regionKey.region();
ByteRange regionRange = ByteRange.of(0, computeCacheFileRegionSize(blobLength, region));
if (regionRange.isEmpty() == false) {
List<SparseFileTracker.Gap> regionGaps = toFetch.tracker.waitForRange(
regionRange,
regionRange,
regionsListener.acquire()
);
if (regionGaps.isEmpty() == false) {
gaps.add(new Tuple<>(toFetch, new RegionGaps(toFetch.regionKey.region(), regionGaps)));
gaps.add(new Tuple<>(toFetch, new RegionGaps((long) region * regionSize, regionGaps)));
}
}
}
Expand Down Expand Up @@ -1070,7 +1071,7 @@ void populate(
return;
}
final SourceInputStreamFactory streamFactory = writer.sharedInputStreamFactory(
new RegionGaps(regionKey.region(), gaps)
new RegionGaps((long) regionKey.region() * blobCacheService.getRegionSize(), gaps)
);
logger.trace(
() -> Strings.format(
Expand Down Expand Up @@ -1149,7 +1150,7 @@ void populateAndRead(

if (gaps.isEmpty() == false) {
final SourceInputStreamFactory streamFactory = writer.sharedInputStreamFactory(
new RegionGaps(regionKey.region(), gaps)
new RegionGaps((long) regionKey.region() * blobCacheService.getRegionSize(), gaps)
);
logger.trace(
() -> Strings.format(
Expand Down Expand Up @@ -1248,7 +1249,7 @@ protected void alreadyClosed() {
}
}

public record RegionGaps(int region, List<SparseFileTracker.Gap> gaps) {}
public record RegionGaps(long regionOffset, List<SparseFileTracker.Gap> gaps) {}

public class CacheFile {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.elasticsearch.blobcache.BlobCacheMetrics;
import org.elasticsearch.blobcache.BlobCacheUtils;
import org.elasticsearch.blobcache.common.ByteRange;
import org.elasticsearch.blobcache.common.SparseFileTracker;
import org.elasticsearch.blobcache.shared.SharedBlobCacheService.RangeMissingHandler;
import org.elasticsearch.blobcache.shared.SharedBlobCacheService.SourceInputStreamFactory;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
Expand Down

0 comments on commit 19deaac

Please sign in to comment.