This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-3 by this push:
     new a66ff5bdbd5 HBASE-28861 Use hasReferences() api of SFT in 
RegionSplitter and remove Reference.read(), HRegionFS.hasReferences() (#6428)
a66ff5bdbd5 is described below

commit a66ff5bdbd5f43f73c61ab374416af3710d8fe91
Author: gvprathyusha6 <[email protected]>
AuthorDate: Thu Jan 23 21:38:00 2025 +0530

    HBASE-28861 Use hasReferences() api of SFT in RegionSplitter and remove 
Reference.read(), HRegionFS.hasReferences() (#6428)
    
    Signed-off-by: Andrew Purtell <[email protected]>
    Co-authored-by: Prathyusha Garre 
<[email protected]>
---
 .../java/org/apache/hadoop/hbase/io/Reference.java | 34 ----------------------
 .../hbase/regionserver/HRegionFileSystem.java      | 22 --------------
 .../compaction/TestMajorCompactionRequest.java     |  2 --
 3 files changed, 58 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/Reference.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/Reference.java
index 22d3c9ce2c0..5388a1105c3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/Reference.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/Reference.java
@@ -17,13 +17,9 @@
  */
 package org.apache.hadoop.hbase.io;
 
-import java.io.BufferedInputStream;
 import java.io.DataInput;
-import java.io.DataInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Arrays;
-import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -144,36 +140,6 @@ public class Reference {
     return p;
   }
 
-  /**
-   * Read a Reference from FileSystem.
-   * @return New Reference made from passed <code>p</code>
-   */
-  public static Reference read(final FileSystem fs, final Path p) throws 
IOException {
-    InputStream in = fs.open(p);
-    try {
-      // I need to be able to move back in the stream if this is not a pb 
serialization so I can
-      // do the Writable decoding instead.
-      in = in.markSupported() ? in : new BufferedInputStream(in);
-      int pblen = ProtobufUtil.lengthOfPBMagic();
-      in.mark(pblen);
-      byte[] pbuf = new byte[pblen];
-      IOUtils.readFully(in, pbuf, 0, pblen);
-      // WATCHOUT! Return in middle of function!!!
-      if (ProtobufUtil.isPBMagicPrefix(pbuf)) return 
convert(FSProtos.Reference.parseFrom(in));
-      // Else presume Writables. Need to reset the stream since it didn't 
start w/ pb.
-      // We won't bother rewriting thie Reference as a pb since Reference is 
transitory.
-      in.reset();
-      Reference r = new Reference();
-      DataInputStream dis = new DataInputStream(in);
-      // Set in = dis so it gets the close below in the finally on our way out.
-      in = dis;
-      r.readFields(dis);
-      return r;
-    } finally {
-      in.close();
-    }
-  }
-
   public FSProtos.Reference convert() {
     FSProtos.Reference.Builder builder = FSProtos.Reference.newBuilder();
     builder.setRange(isTopFileRegion(getFileRegion())
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
index 6f1ba4f6b40..e4ccedda0c2 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
@@ -313,28 +313,6 @@ public class HRegionFileSystem {
       familyName, new Path(familyDir, fileName), tracker);
   }
 
-  /**
-   * Returns true if the specified family has reference files
-   * @param familyName Column Family Name
-   * @return true if family contains reference files
-   */
-  public boolean hasReferences(final String familyName) throws IOException {
-    Path storeDir = getStoreDir(familyName);
-    FileStatus[] files = CommonFSUtils.listStatus(fs, storeDir);
-    if (files != null) {
-      for (FileStatus stat : files) {
-        if (stat.isDirectory()) {
-          continue;
-        }
-        if (StoreFileInfo.isReference(stat.getPath())) {
-          LOG.trace("Reference {}", stat.getPath());
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-
   /** Returns the set of families present on disk n */
   public Collection<String> getFamilies() throws IOException {
     FileStatus[] fds =
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/compaction/TestMajorCompactionRequest.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/compaction/TestMajorCompactionRequest.java
index f05226fdad8..1d48127f7d0 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/compaction/TestMajorCompactionRequest.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/compaction/TestMajorCompactionRequest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.isA;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
@@ -146,7 +145,6 @@ public class TestMajorCompactionRequest {
     HRegionFileSystem mockSystem = mock(HRegionFileSystem.class);
     doReturn(info).when(mockSystem).getRegionInfo();
     doReturn(regionStoreDir).when(mockSystem).getStoreDir(FAMILY);
-    doReturn(hasReferenceFiles).when(mockSystem).hasReferences(anyString());
     doReturn(fileSystem).when(mockSystem).getFileSystem();
     return mockSystem;
   }

Reply via email to