Search in sources :

Example 1 with NamenodeStats

use of com.facebook.presto.hive.NamenodeStats in project presto by prestodb.

the class TestHiveFileIterator method testPathFilterWithRecursion.

@Test
public void testPathFilterWithRecursion() 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);
    // create two directories
    List<File> subDirs = createDirs(basePath, 2);
    // create 5 files in dir1 - 3 pathFilter matched and 2 non matched files.
    String dir1 = subDirs.get(0).getAbsolutePath();
    createFiles(dir1, 3, true);
    createFiles(dir1, 2, false);
    // create 7 files in dir2 - 3 pathFilter matched and 4 non matched files.
    String dir2 = subDirs.get(1).getAbsolutePath();
    createFiles(dir2, 3, true);
    createFiles(dir2, 4, 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(), RECURSE, pathFilter);
    int actualCount = Iterators.size(hiveFileIterator);
    assertEquals(actualCount, 9);
    // 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 NamenodeStats

use of com.facebook.presto.hive.NamenodeStats in project presto by prestodb.

the class TestHiveFileIterator method testDefaultPathFilterWithRecursion.

@Test
public void testDefaultPathFilterWithRecursion() 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);
    // create two directories
    List<File> subDirs = createDirs(basePath, 2);
    // create 5 files in dir1 - 3 pathFilter matched and 2 non matched files.
    String dir1 = subDirs.get(0).getAbsolutePath();
    createFiles(dir1, 3, true);
    createFiles(dir1, 2, false);
    // create 7 files in dir2 - 3 pathFilter matched and 4 non matched files.
    String dir2 = subDirs.get(1).getAbsolutePath();
    createFiles(dir2, 3, true);
    createFiles(dir2, 4, false);
    Path rootPath = new Path("file://" + basePath + File.separator);
    PathFilter pathFilter = path -> true;
    HiveFileIterator hiveFileIterator = new HiveFileIterator(rootPath, listDirectoryOperation, new NamenodeStats(), RECURSE, pathFilter);
    int actualCount = Iterators.size(hiveFileIterator);
    assertEquals(actualCount, 20);
    // 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 3 with NamenodeStats

use of com.facebook.presto.hive.NamenodeStats 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 4 with NamenodeStats

use of com.facebook.presto.hive.NamenodeStats 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)4 NamenodeStats (com.facebook.presto.hive.NamenodeStats)4 IGNORED (com.facebook.presto.hive.NestedDirectoryPolicy.IGNORED)4 RECURSE (com.facebook.presto.hive.NestedDirectoryPolicy.RECURSE)4 ListDirectoryOperation (com.facebook.presto.hive.util.HiveFileIterator.ListDirectoryOperation)4 Iterators (com.google.common.collect.Iterators)4 Files.createTempDir (com.google.common.io.Files.createTempDir)4 MoreFiles.deleteRecursively (com.google.common.io.MoreFiles.deleteRecursively)4 ALLOW_INSECURE (com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE)4 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Configuration (org.apache.hadoop.conf.Configuration)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 Path (org.apache.hadoop.fs.Path)4 PathFilter (org.apache.hadoop.fs.PathFilter)4 Assert.assertEquals (org.testng.Assert.assertEquals)4 AfterClass (org.testng.annotations.AfterClass)4 BeforeClass (org.testng.annotations.BeforeClass)4