| 38 | */ |
| 39 | public class RowCount { |
| 40 | public static void main(Configuration conf, String[] args) throws Exception { |
| 41 | Options opts = createOptions(); |
| 42 | CommandLine cli = new DefaultParser().parse(opts, args); |
| 43 | if (cli.hasOption('h')) { |
| 44 | HelpFormatter formatter = new HelpFormatter(); |
| 45 | formatter.printHelp("count", opts); |
| 46 | return; |
| 47 | } |
| 48 | boolean ignoreExtension = cli.hasOption("ignoreExtension"); |
| 49 | String[] files = cli.getArgs(); |
| 50 | |
| 51 | int bad = 0; |
| 52 | for(String root: files) { |
| 53 | Path rootPath = new Path(root); |
| 54 | FileSystem fs = rootPath.getFileSystem(conf); |
| 55 | for(RemoteIterator<LocatedFileStatus> itr = fs.listFiles(rootPath, true); itr.hasNext(); ) { |
| 56 | LocatedFileStatus status = itr.next(); |
| 57 | if (status.isFile() && (ignoreExtension || status.getPath().getName().endsWith(".orc"))) { |
| 58 | Path filename = status.getPath(); |
| 59 | try (Reader reader = OrcFile.createReader(filename, OrcFile.readerOptions(conf))) { |
| 60 | System.out.println(String.format("%s %d", |
| 61 | filename.toString(), reader.getNumberOfRows())); |
| 62 | } catch (IOException ioe) { |
| 63 | bad += 1; |
| 64 | System.err.println("Failed to read " + filename); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | if (bad > 0) { |
| 70 | System.exit(1); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | public static void main(String[] args) throws Exception { |
| 75 | Configuration conf = new Configuration(); |