Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.hudi.hadoop;

import com.google.common.annotations.VisibleForTesting;
import org.apache.hudi.common.config.SerializableConfiguration;
import org.apache.hudi.common.engine.HoodieLocalEngineContext;
import org.apache.hudi.common.fs.FSUtils;
Expand Down Expand Up @@ -173,6 +174,13 @@ public boolean accept(Path path) {
}

if (baseDir != null) {
// Check whether baseDir in nonHoodiePathCache
if (nonHoodiePathCache.contains(baseDir.toString())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Accepting non-hoodie path from cache: " + path);
}
return true;
}
HoodieTableFileSystemView fsView = null;
try {
HoodieTableMetaClient metaClient = metaClientCache.get(baseDir.toString());
Expand Down Expand Up @@ -211,9 +219,10 @@ public boolean accept(Path path) {
} catch (TableNotFoundException e) {
// Non-hoodie path, accept it.
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("(1) Caching non-hoodie path under %s \n", folder.toString()));
LOG.debug(String.format("(1) Caching non-hoodie path under %s and %s \n", folder.toString(), baseDir.toString()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path under %s and %s might confuse users. Maybe, path under %s with basePath %s would be more clear

}
nonHoodiePathCache.add(folder.toString());
nonHoodiePathCache.add(baseDir.toString());
return true;
}
} else {
Expand All @@ -231,6 +240,12 @@ public boolean accept(Path path) {
}
}

@VisibleForTesting
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As CheckStyle doesn't encourage to import com.google.common.annotations.VisibleForTesting annotation. I simply follow metaClientCache to make nonHoodiePathCache access specifier is friendly for test purpose.

public Set<String> getNonHoodiePathCache() {
return nonHoodiePathCache;
}


@Override
public void setConf(Configuration conf) {
this.conf = new SerializableConfiguration(conf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void testHoodiePaths() throws Exception {
assertFalse(pathFilter.accept(new Path("file:///" + basePath + "/" + HoodieTableMetaClient.METAFOLDER_NAME)));

assertEquals(1, pathFilter.metaClientCache.size());
assertEquals(0, pathFilter.getNonHoodiePathCache().size(), "NonHoodiePathCache size should be 0");
}

@Test
Expand All @@ -82,6 +83,7 @@ public void testNonHoodiePaths() throws IOException {
java.nio.file.Path path2 = Paths.get(basePath, "nonhoodiefolder/somefile");
Files.createFile(path2);
assertTrue(pathFilter.accept(new Path(path2.toUri())));
assertEquals(2, pathFilter.getNonHoodiePathCache().size(), "NonHoodiePathCache size should be 2");
}

@Test
Expand All @@ -93,5 +95,6 @@ public void testPartitionPathsAsNonHoodiePaths() throws Exception {
Path partitionPath2 = testTable.getPartitionPath(p2).getParent();
assertTrue(pathFilter.accept(partitionPath1), "Directories should be accepted");
assertTrue(pathFilter.accept(partitionPath2), "Directories should be accepted");
assertEquals(2, pathFilter.getNonHoodiePathCache().size(), "NonHoodiePathCache size should be 2");
}
}