| 62 | } |
| 63 | |
| 64 | public static void main(String[] args) throws Exception { |
| 65 | DriverOptions options = new DriverOptions(args); |
| 66 | |
| 67 | if (options.command == null) { |
| 68 | System.err.println("ORC Java Examples"); |
| 69 | System.err.println(); |
| 70 | System.err.println("usage: java -jar orc-examples-*-uber.jar [--help]" + |
| 71 | " [--define X=Y] <command> <args>"); |
| 72 | System.err.println(); |
| 73 | System.err.println("Commands:"); |
| 74 | System.err.println(" write - write a sample ORC file"); |
| 75 | System.err.println(" read - read a sample ORC file"); |
| 76 | System.err.println(" write2 - write a sample ORC file with a map"); |
| 77 | System.err.println(" read2 - read a sample ORC file with a map"); |
| 78 | System.err.println(" compressWriter - write a ORC file with snappy compression"); |
| 79 | System.err.println(" inMemoryEncryptionWriter - write a ORC file with encryption"); |
| 80 | System.err.println(" inMemoryEncryptionReader - read a ORC file with encryption"); |
| 81 | System.err.println(); |
| 82 | System.err.println("To get more help, provide -h to the command"); |
| 83 | System.exit(1); |
| 84 | } |
| 85 | Configuration conf = new Configuration(); |
| 86 | String[] confSettings = options.genericOptions.getOptionValues("D"); |
| 87 | if (confSettings != null) { |
| 88 | for (String param : confSettings) { |
| 89 | String[] parts = param.split("=", 2); |
| 90 | conf.set(parts[0], parts[1]); |
| 91 | } |
| 92 | } |
| 93 | if ("read".equals(options.command)) { |
| 94 | CoreReader.main(conf, options.commandArgs); |
| 95 | } else if ("write".equals(options.command)) { |
| 96 | CoreWriter.main(conf, options.commandArgs); |
| 97 | } else if ("write2".equals(options.command)) { |
| 98 | AdvancedWriter.main(conf, options.commandArgs); |
| 99 | } else if ("read2".equals(options.command)) { |
| 100 | AdvancedReader.main(conf, options.commandArgs); |
| 101 | } else if ("compressWriter".equals(options.command)) { |
| 102 | CompressionWriter.main(conf, options.commandArgs); |
| 103 | } else if ("inMemoryEncryptionWriter".equals(options.command)) { |
| 104 | InMemoryEncryptionWriter.main(conf, options.commandArgs); |
| 105 | } else if ("inMemoryEncryptionReader".equals(options.command)) { |
| 106 | InMemoryEncryptionReader.main(conf, options.commandArgs); |
| 107 | } else { |
| 108 | System.err.println("Unknown subcommand: " + options.command); |
| 109 | System.exit(1); |
| 110 | } |
| 111 | } |
| 112 | } |