@Test public void testBzip2SequenceFileCompression() throws Exception { runSequenceFileCompressionTest(new BZip2Codec(), 4); } }
@Test public void testDefaultTextCompression() throws IOException { runTextCompressionTest(null, 4); }
public void runTextCompressionTest(CompressionCodec codec, int expectedNum) throws IOException { String [] columns = HsqldbTestServer.getFieldNames(); String [] argv = getArgv(true, columns, codec, "--as-textfile"); runImport(argv); Configuration conf = new Configuration(); if (!BaseSqoopTestCase.isOnPhysicalCluster()) { conf.set(CommonArgs.FS_DEFAULT_NAME, CommonArgs.LOCAL_FS); } FileSystem fs = FileSystem.get(conf); if (codec == null) { codec = new GzipCodec(); } ReflectionUtils.setConf(codec, getConf()); Path p = new Path(getDataFilePath().toString() + codec.getDefaultExtension()); InputStream is = codec.createInputStream(fs.open(p)); BufferedReader r = new BufferedReader(new InputStreamReader(is)); int numLines = 0; while (true) { String ln = r.readLine(); if (ln == null) { break; } numLines++; } r.close(); assertEquals(expectedNum, numLines); }
SequenceFile.Reader reader = null; String [] argv = getArgv(true, columns, codec, "--as-sequencefile"); runImport(argv); try { SqoopOptions opts = new ImportTool().parseArguments( getArgv(false, columns, codec, "--as-sequencefile"), null, null, true); getTableName()); reader = SeqFileReader.getSeqFileReader(getDataFilePath().toString());
args.add(getWarehouseDir()); args.add("--connect"); args.add(HsqldbTestServer.getUrl());
@Test public void testBzip2TextCompression() throws IOException { runTextCompressionTest(new BZip2Codec(), 4); }