Skip to content

Commit 9c3d569

Browse files
committed
HBASE-29272 When Spark reads an HBase snapshot, it always read empty data.
HBASE-29272 When Spark reads an HBase snapshot, it always read empty data.
1 parent 5f5ee39 commit 9c3d569

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotRegionSizeCalculator.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ public SnapshotRegionSizeCalculator(Configuration conf, SnapshotManifest manifes
4646
throws IOException {
4747
this.conf = conf;
4848
this.manifest = manifest;
49-
this.regionSizes = calculateRegionSizes();
5049
Path rootDir = CommonFSUtils.getRootDir(conf);
51-
fs = FileSystem.get(rootDir.toUri(), conf);
50+
this.fs = FileSystem.get(rootDir.toUri(), conf);
51+
this.regionSizes = calculateRegionSizes();
5252
}
5353

5454
/**
5555
* Calculate the size of each region in the snapshot.
5656
* @return A map of region encoded names to their total size in bytes.
57+
* @throws IOException If an error occurs during calculation.
5758
*/
5859
public Map<String, Long> calculateRegionSizes() throws IOException {
5960
SnapshotProtos.SnapshotDescription snapshot =
@@ -62,6 +63,11 @@ public Map<String, Long> calculateRegionSizes() throws IOException {
6263
return stats.getRegionSizeMap();
6364
}
6465

66+
/**
67+
* Retrieves the size of a specific region by its encoded name.
68+
* @param encodedRegionName The encoded name of the region.
69+
* @return The size of the region in bytes, or 0 if the region is not found.
70+
*/
6571
public long getRegionSize(String encodedRegionName) {
6672
Long size = regionSizes.get(encodedRegionName);
6773
if (size == null) {

0 commit comments

Comments
 (0)