5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-02 17:59:21 +08:00

Eliminate checkstyle warnings.

From: Aaron Kimball <aaron@cloudera.com>

git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1149909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Bayer 2011-07-22 20:03:55 +00:00
parent 8db82cd9d1
commit 383e46201c
10 changed files with 47 additions and 28 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Licensed to Cloudera, Inc. under one or more # Licensed to Cloudera, Inc. under one or more
# contributor license agreements. See the NOTICE file distributed with # contributor license agreements. See the NOTICE file distributed with

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Licensed to Cloudera, Inc. under one or more # Licensed to Cloudera, Inc. under one or more
# contributor license agreements. See the NOTICE file distributed with # contributor license agreements. See the NOTICE file distributed with

View File

@ -156,6 +156,8 @@ public List<String> parseRecord(ByteBuffer input) throws ParseError {
return parseRecord(input.asCharBuffer()); return parseRecord(input.asCharBuffer());
} }
// TODO(aaron): Refactor this method to be much shorter.
// CHECKSTYLE:OFF
/** /**
* Return a list of strings representing the fields of the input line. * Return a list of strings representing the fields of the input line.
* This list is backed by an internal buffer which is cleared by the * This list is backed by an internal buffer which is cleared by the
@ -236,6 +238,7 @@ record sep halts processing.
state = ParseState.UNENCLOSED_ESCAPE; state = ParseState.UNENCLOSED_ESCAPE;
} else if (fieldDelim == curChar) { } else if (fieldDelim == curChar) {
// we have a zero-length field. This is a no-op. // we have a zero-length field. This is a no-op.
continue;
} else if (recordDelim == curChar) { } else if (recordDelim == curChar) {
// we have a zero-length field, that ends processing. // we have a zero-length field, that ends processing.
pos = len; pos = len;
@ -337,6 +340,7 @@ record sep halts processing.
return outputs; return outputs;
} }
// CHECKSTYLE:ON
public boolean isEnclosingRequired() { public boolean isEnclosingRequired() {
return delimiters.isEncloseRequired(); return delimiters.isEncloseRequired();

View File

@ -275,6 +275,8 @@ private String writePasswordFile(String password) throws IOException {
return tempFile.toString(); return tempFile.toString();
} }
// TODO(aaron): Refactor this method to be much shorter.
// CHECKSTYLE:OFF
@Override @Override
/** /**
* Import the table into HDFS by using psql to pull the data out of the db * Import the table into HDFS by using psql to pull the data out of the db
@ -460,4 +462,5 @@ public void importTable(ImportJobContext context)
LOG.info("Transferred " + counters.toString()); LOG.info("Transferred " + counters.toString());
} }
} }
// CHECKSTYLE:ON
} }

View File

@ -275,7 +275,8 @@ private void setSessionTimeZone(Connection conn) throws SQLException {
LOG.info("Setting default time zone: GMT"); LOG.info("Setting default time zone: GMT");
try { try {
// Per the documentation at: // Per the documentation at:
// http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14225/applocaledata.htm#i637736 // http://download-west.oracle.com/docs/cd/B19306_01
// /server.102/b14225/applocaledata.htm#i637736
// The "GMT" timezone is guaranteed to exist in the available timezone // The "GMT" timezone is guaranteed to exist in the available timezone
// regions, whereas others (e.g., "UTC") are not. // regions, whereas others (e.g., "UTC") are not.
method.invoke(conn, "GMT"); method.invoke(conn, "GMT");

View File

@ -78,7 +78,8 @@ protected void configureMapper(Job job, String tableName,
protected Class<? extends Mapper> getMapperClass() { protected Class<? extends Mapper> getMapperClass() {
if (options.getFileLayout() == SqoopOptions.FileLayout.TextFile) { if (options.getFileLayout() == SqoopOptions.FileLayout.TextFile) {
return TextImportMapper.class; return TextImportMapper.class;
} else if (options.getFileLayout() == SqoopOptions.FileLayout.SequenceFile) { } else if (options.getFileLayout()
== SqoopOptions.FileLayout.SequenceFile) {
return SequenceFileImportMapper.class; return SequenceFileImportMapper.class;
} }
@ -91,7 +92,8 @@ protected Class<? extends OutputFormat> getOutputFormatClass()
if (options.getFileLayout() == SqoopOptions.FileLayout.TextFile) { if (options.getFileLayout() == SqoopOptions.FileLayout.TextFile) {
return (Class<? extends OutputFormat>) ShimLoader.getShimClass( return (Class<? extends OutputFormat>) ShimLoader.getShimClass(
"com.cloudera.sqoop.mapreduce.RawKeyTextOutputFormat"); "com.cloudera.sqoop.mapreduce.RawKeyTextOutputFormat");
} else if (options.getFileLayout() == SqoopOptions.FileLayout.SequenceFile) { } else if (options.getFileLayout()
== SqoopOptions.FileLayout.SequenceFile) {
return SequenceFileOutputFormat.class; return SequenceFileOutputFormat.class;
} }

View File

@ -305,6 +305,8 @@ public void run() {
} }
} }
// TODO(aaron): Refactor this method to be much shorter.
// CHECKSTYLE:OFF
/** /**
* Import the table into HDFS by using mysqldump to pull out the data from * Import the table into HDFS by using mysqldump to pull out the data from
* the database and upload the files directly to HDFS. * the database and upload the files directly to HDFS.
@ -483,6 +485,7 @@ public void map(String splitConditions, NullWritable val, Context context)
LOG.info("Transferred " + counters.toString()); LOG.info("Transferred " + counters.toString());
} }
} }
// CHECKSTYLE:ON
@Override @Override
protected void setup(Context context) { protected void setup(Context context) {

View File

@ -205,5 +205,10 @@
--> -->
<!-- module name="TodoComment"/ --> <!-- module name="TodoComment"/ -->
<module name="UpperEll"/> <module name="UpperEll"/>
<module name="FileContentsHolder" />
</module> </module>
<!-- allow warnings to be suppressed -->
<module name="SuppressionCommentFilter" />
</module> </module>

View File

@ -245,7 +245,8 @@ public void testOracleImport() throws IOException {
// columns as DATE in Oracle, they may still contain time information, so // columns as DATE in Oracle, they may still contain time information, so
// the JDBC drivers lie to us and will never tell us we have a strict DATE // the JDBC drivers lie to us and will never tell us we have a strict DATE
// type. Thus we include HH:MM:SS.mmmmm below. // type. Thus we include HH:MM:SS.mmmmm below.
// See http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#08_01 // See http://www.oracle.com
// /technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#08_01
String [] expectedResults = { String [] expectedResults = {
"1,Aaron,2009-05-14 00:00:00.0,1000000,engineering," "1,Aaron,2009-05-14 00:00:00.0,1000000,engineering,"
+ "2009-12-29 12:00:00.0,2009-12-29 12:00:00.0", + "2009-12-29 12:00:00.0,2009-12-29 12:00:00.0",

View File

@ -62,10 +62,10 @@
*/ */
public abstract class ManagerCompatTestCase extends ImportJobTestCase { public abstract class ManagerCompatTestCase extends ImportJobTestCase {
public Log LOG; private Log log;
public ManagerCompatTestCase() { public ManagerCompatTestCase() {
this.LOG = LogFactory.getLog(ManagerCompatTestCase.class.getName()); this.log = LogFactory.getLog(ManagerCompatTestCase.class.getName());
} }
/** /**
@ -94,7 +94,7 @@ protected boolean useHsqldbTestServer() {
@Override @Override
public void setUp() { public void setUp() {
LOG = getLogger(); log = getLogger();
skipped = false; skipped = false;
super.setUp(); super.setUp();
} }
@ -105,7 +105,7 @@ public void tearDown() {
// Clean up the database on our way out. // Clean up the database on our way out.
dropTableIfExists(getTableName()); dropTableIfExists(getTableName());
} catch (SQLException e) { } catch (SQLException e) {
LOG.warn("Error trying to drop table '" + getTableName() log.warn("Error trying to drop table '" + getTableName()
+ "' on tearDown: " + e); + "' on tearDown: " + e);
} }
super.tearDown(); super.tearDown();
@ -615,7 +615,7 @@ public void testNullInt() {
@Test @Test
public void testBoolean() { public void testBoolean() {
if (!supportsBoolean()) { if (!supportsBoolean()) {
LOG.info("Skipping boolean test (unsupported)"); log.info("Skipping boolean test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -625,7 +625,7 @@ public void testBoolean() {
@Test @Test
public void testBoolean2() { public void testBoolean2() {
if (!supportsBoolean()) { if (!supportsBoolean()) {
LOG.info("Skipping boolean test (unsupported)"); log.info("Skipping boolean test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -635,7 +635,7 @@ public void testBoolean2() {
@Test @Test
public void testBoolean3() { public void testBoolean3() {
if (!supportsBoolean()) { if (!supportsBoolean()) {
LOG.info("Skipping boolean test (unsupported)"); log.info("Skipping boolean test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -646,7 +646,7 @@ public void testBoolean3() {
@Test @Test
public void testTinyInt1() { public void testTinyInt1() {
if (!supportsTinyInt()) { if (!supportsTinyInt()) {
LOG.info("Skipping tinyint test (unsupported)"); log.info("Skipping tinyint test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -656,7 +656,7 @@ public void testTinyInt1() {
@Test @Test
public void testTinyInt2() { public void testTinyInt2() {
if (!supportsTinyInt()) { if (!supportsTinyInt()) {
LOG.info("Skipping tinyint test (unsupported)"); log.info("Skipping tinyint test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -676,7 +676,7 @@ public void testSmallInt2() {
@Test @Test
public void testBigInt1() { public void testBigInt1() {
if (!supportsBigInt()) { if (!supportsBigInt()) {
LOG.info("Skipping bigint test (unsupported)"); log.info("Skipping bigint test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -743,7 +743,7 @@ public void testDate3() {
@Test @Test
public void testTime1() { public void testTime1() {
if (!supportsTime()) { if (!supportsTime()) {
LOG.info("Skipping time test (unsupported)"); log.info("Skipping time test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -753,7 +753,7 @@ public void testTime1() {
@Test @Test
public void testTime2() { public void testTime2() {
if (!supportsTime()) { if (!supportsTime()) {
LOG.info("Skipping time test (unsupported)"); log.info("Skipping time test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -763,7 +763,7 @@ public void testTime2() {
@Test @Test
public void testTime3() { public void testTime3() {
if (!supportsTime()) { if (!supportsTime()) {
LOG.info("Skipping time test (unsupported)"); log.info("Skipping time test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -773,7 +773,7 @@ public void testTime3() {
@Test @Test
public void testTime4() { public void testTime4() {
if (!supportsTime()) { if (!supportsTime()) {
LOG.info("Skipping time test (unsupported)"); log.info("Skipping time test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -791,23 +791,23 @@ public void testTimestamp1() {
@Test @Test
public void testTimestamp2() { public void testTimestamp2() {
try { try {
LOG.debug("Beginning testTimestamp2"); log.debug("Beginning testTimestamp2");
verifyType(getTimestampType(), verifyType(getTimestampType(),
getTimestampInsertStr("'2009-04-24 18:24:00.0002'"), getTimestampInsertStr("'2009-04-24 18:24:00.0002'"),
getTimestampDbOutput("2009-04-24 18:24:00.0002"), getTimestampDbOutput("2009-04-24 18:24:00.0002"),
getTimestampSeqOutput("2009-04-24 18:24:00.0002")); getTimestampSeqOutput("2009-04-24 18:24:00.0002"));
} finally { } finally {
LOG.debug("End testTimestamp2"); log.debug("End testTimestamp2");
} }
} }
@Test @Test
public void testTimestamp3() { public void testTimestamp3() {
try { try {
LOG.debug("Beginning testTimestamp3"); log.debug("Beginning testTimestamp3");
verifyType(getTimestampType(), "null", null); verifyType(getTimestampType(), "null", null);
} finally { } finally {
LOG.debug("End testTimestamp3"); log.debug("End testTimestamp3");
} }
} }
@ -905,7 +905,7 @@ public void testDecimal6() {
@Test @Test
public void testLongVarChar() { public void testLongVarChar() {
if (!supportsLongVarChar()) { if (!supportsLongVarChar()) {
LOG.info("Skipping long varchar test (unsupported)"); log.info("Skipping long varchar test (unsupported)");
skipped = true; skipped = true;
return; return;
} }
@ -942,7 +942,7 @@ protected void verifyBlob(String insertVal, byte [] returnVal,
assertTrue("Expected at least one row returned", results.next()); assertTrue("Expected at least one row returned", results.next());
Blob blob = results.getBlob(2); Blob blob = results.getBlob(2);
byte [] databaseBytes = blob.getBytes(1, (int) blob.length()); byte [] databaseBytes = blob.getBytes(1, (int) blob.length());
LOG.info("Verifying readback of bytes from " + getTableName()); log.info("Verifying readback of bytes from " + getTableName());
assertEquals("byte arrays differ in size", returnVal.length, assertEquals("byte arrays differ in size", returnVal.length,
databaseBytes.length); databaseBytes.length);
@ -977,7 +977,7 @@ protected void verifyBlob(String insertVal, byte [] returnVal,
@Test @Test
public void testClob1() { public void testClob1() {
if (!supportsClob()) { if (!supportsClob()) {
LOG.info("Skipping CLOB test; database does not support CLOB"); log.info("Skipping CLOB test; database does not support CLOB");
return; return;
} }
@ -989,7 +989,7 @@ public void testClob1() {
@Test @Test
public void testBlob1() { public void testBlob1() {
if (!supportsBlob()) { if (!supportsBlob()) {
LOG.info("Skipping BLOB test; database does not support BLOB"); log.info("Skipping BLOB test; database does not support BLOB");
return; return;
} }