| 79 | } |
| 80 | |
| 81 | public static void main(Configuration conf, String[] args) throws Exception { |
| 82 | List<Integer> rowIndexCols = new ArrayList<>(0); |
| 83 | Options opts = createOptions(); |
| 84 | CommandLine cli = new DefaultParser().parse(opts, args); |
| 85 | |
| 86 | if (cli.hasOption('h')) { |
| 87 | HelpFormatter formatter = new HelpFormatter(); |
| 88 | formatter.printHelp("meta", opts); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | boolean dumpData = cli.hasOption('d'); |
| 93 | boolean recover = cli.hasOption("recover"); |
| 94 | boolean skipDump = cli.hasOption("skip-dump"); |
| 95 | String backupPath = DEFAULT_BACKUP_PATH; |
| 96 | if (cli.hasOption("backup-path")) { |
| 97 | backupPath = cli.getOptionValue("backup-path"); |
| 98 | } |
| 99 | |
| 100 | if (cli.hasOption("r")) { |
| 101 | String val = cli.getOptionValue("r"); |
| 102 | if (val != null && val.trim().equals("*")) { |
| 103 | rowIndexCols = null; // All the columns |
| 104 | } else { |
| 105 | String[] colStrs = cli.getOptionValue("r").split(","); |
| 106 | rowIndexCols = new ArrayList<>(colStrs.length); |
| 107 | for (String colStr : colStrs) { |
| 108 | rowIndexCols.add(Integer.parseInt(colStr)); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | boolean printTimeZone = cli.hasOption('t'); |
| 114 | boolean jsonFormat = cli.hasOption('j'); |
| 115 | String[] files = cli.getArgs(); |
| 116 | if (files.length == 0) { |
| 117 | System.err.println("Error : ORC files are not specified"); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | // if the specified path is directory, iterate through all files and print the file dump |
| 122 | List<String> filesInPath = new ArrayList<>(); |
| 123 | for (String filename : files) { |
| 124 | Path path = new Path(filename); |
| 125 | filesInPath.addAll(getAllFilesInPath(path, conf)); |
| 126 | } |
| 127 | |
| 128 | if (dumpData) { |
| 129 | PrintData.main(conf, filesInPath.toArray(new String[filesInPath.size()])); |
| 130 | } else if (recover && skipDump) { |
| 131 | recoverFiles(filesInPath, conf, backupPath); |
| 132 | } else { |
| 133 | if (jsonFormat) { |
| 134 | boolean prettyPrint = cli.hasOption('p'); |
| 135 | JsonFileDump.printJsonMetaData(filesInPath, conf, rowIndexCols, prettyPrint, printTimeZone); |
| 136 | } else { |
| 137 | boolean printColumnType = cli.hasOption("column-type"); |
| 138 | printMetaData(filesInPath, conf, rowIndexCols, printTimeZone, recover, backupPath, |