Search in sources :

Example 1 with IGNORED

use of com.facebook.presto.hive.NestedDirectoryPolicy.IGNORED in project presto by prestodb.

the class TestHiveFileIterator method testDefaultPathFilterNoRecursion.

@Test
public void testDefaultPathFilterNoRecursion() throws IOException {
    // set up
    File rootDir = createTempDir();
    String basePath = rootDir.getAbsolutePath();
    // create 8 files in root directory - 3 pathFilter matched and 5 non matched files.
    createFiles(basePath, 3, true);
    createFiles(basePath, 5, false);
    Path rootPath = new Path("file://" + basePath + File.separator);
    PathFilter pathFilter = path -> true;
    HiveFileIterator hiveFileIterator = new HiveFileIterator(rootPath, listDirectoryOperation, new NamenodeStats(), IGNORED, pathFilter);
    int actualCount = Iterators.size(hiveFileIterator);
    assertEquals(actualCount, 8);
    // cleanup
    deleteTestDir(rootDir);
}
Also used : Path(org.apache.hadoop.fs.Path) AfterClass(org.testng.annotations.AfterClass) Files.createTempDir(com.google.common.io.Files.createTempDir) FileSystem(org.apache.hadoop.fs.FileSystem) MoreFiles.deleteRecursively(com.google.common.io.MoreFiles.deleteRecursively) BeforeClass(org.testng.annotations.BeforeClass) ListDirectoryOperation(com.facebook.presto.hive.util.HiveFileIterator.ListDirectoryOperation) PathFilter(org.apache.hadoop.fs.PathFilter) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) IOException(java.io.IOException) Iterators(com.google.common.collect.Iterators) File(java.io.File) ArrayList(java.util.ArrayList) List(java.util.List) IGNORED(com.facebook.presto.hive.NestedDirectoryPolicy.IGNORED) ALLOW_INSECURE(com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE) Configuration(org.apache.hadoop.conf.Configuration) Path(org.apache.hadoop.fs.Path) RECURSE(com.facebook.presto.hive.NestedDirectoryPolicy.RECURSE) NamenodeStats(com.facebook.presto.hive.NamenodeStats) HadoopFileInfoIterator(com.facebook.presto.hive.HadoopDirectoryLister.HadoopFileInfoIterator) PathFilter(org.apache.hadoop.fs.PathFilter) File(java.io.File) NamenodeStats(com.facebook.presto.hive.NamenodeStats) Test(org.testng.annotations.Test)

Example 2 with IGNORED

use of com.facebook.presto.hive.NestedDirectoryPolicy.IGNORED in project presto by prestodb.

the class TestHiveFileIterator method testPathFilterWithNoRecursion.

@Test
public void testPathFilterWithNoRecursion() throws IOException {
    // set up
    File rootDir = createTempDir();
    String basePath = rootDir.getAbsolutePath();
    // create 8 files in root directory - 3 pathFilter matched and 5 non matched files.
    createFiles(basePath, 3, true);
    createFiles(basePath, 5, false);
    Path rootPath = new Path("file://" + basePath + File.separator);
    PathFilter pathFilter = path -> path.getName().contains(PATH_FILTER_MATCHED_PREFIX);
    HiveFileIterator hiveFileIterator = new HiveFileIterator(rootPath, listDirectoryOperation, new NamenodeStats(), IGNORED, pathFilter);
    int actualCount = Iterators.size(hiveFileIterator);
    assertEquals(actualCount, 3);
    // cleanup
    deleteTestDir(rootDir);
}
Also used : Path(org.apache.hadoop.fs.Path) AfterClass(org.testng.annotations.AfterClass) Files.createTempDir(com.google.common.io.Files.createTempDir) FileSystem(org.apache.hadoop.fs.FileSystem) MoreFiles.deleteRecursively(com.google.common.io.MoreFiles.deleteRecursively) BeforeClass(org.testng.annotations.BeforeClass) ListDirectoryOperation(com.facebook.presto.hive.util.HiveFileIterator.ListDirectoryOperation) PathFilter(org.apache.hadoop.fs.PathFilter) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) IOException(java.io.IOException) Iterators(com.google.common.collect.Iterators) File(java.io.File) ArrayList(java.util.ArrayList) List(java.util.List) IGNORED(com.facebook.presto.hive.NestedDirectoryPolicy.IGNORED) ALLOW_INSECURE(com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE) Configuration(org.apache.hadoop.conf.Configuration) Path(org.apache.hadoop.fs.Path) RECURSE(com.facebook.presto.hive.NestedDirectoryPolicy.RECURSE) NamenodeStats(com.facebook.presto.hive.NamenodeStats) HadoopFileInfoIterator(com.facebook.presto.hive.HadoopDirectoryLister.HadoopFileInfoIterator) PathFilter(org.apache.hadoop.fs.PathFilter) File(java.io.File) NamenodeStats(com.facebook.presto.hive.NamenodeStats) Test(org.testng.annotations.Test)

Aggregations

HadoopFileInfoIterator (com.facebook.presto.hive.HadoopDirectoryLister.HadoopFileInfoIterator)2 NamenodeStats (com.facebook.presto.hive.NamenodeStats)2 IGNORED (com.facebook.presto.hive.NestedDirectoryPolicy.IGNORED)2 RECURSE (com.facebook.presto.hive.NestedDirectoryPolicy.RECURSE)2 ListDirectoryOperation (com.facebook.presto.hive.util.HiveFileIterator.ListDirectoryOperation)2 Iterators (com.google.common.collect.Iterators)2 Files.createTempDir (com.google.common.io.Files.createTempDir)2 MoreFiles.deleteRecursively (com.google.common.io.MoreFiles.deleteRecursively)2 ALLOW_INSECURE (com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Configuration (org.apache.hadoop.conf.Configuration)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 PathFilter (org.apache.hadoop.fs.PathFilter)2 Assert.assertEquals (org.testng.Assert.assertEquals)2 AfterClass (org.testng.annotations.AfterClass)2 BeforeClass (org.testng.annotations.BeforeClass)2