Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Table of Contents

THIS PAGE IS CURRENTLY AT DRAFT STAGE.

No Format
WIP from VB

Table of Contents

Summary

Since Sqoop2 is primarily JAVA, we will be using the google JAVA coding standards for the most parts. Some of the custom nuances that already exist in Sqoop are also highlighted with code examples,so new contributors spend your time wisely. ! When in doubt, use the google guide as a reference and email the dev@sqoop.apache.org about a convention you deem is important for us to follow.

General Rules

  • No wildcard imports.
  • Overloads appear sequentially.
  • Braces are used even when the body is empty or contains a single statement.
  • 2 spaces indentation.
  • Column limit can be 80 or 100 characters.
  • No C-style array declarations.
  • The default statement in switch statements are required.
  • Modifiers appear in the order recommended by the Java Language Specification.
  • Constants use CONSTANT_CASE. Note that every constant is a static final field, but not all static final fields are constants

Must Follow Rules

License or copyright information

...

If in case, you have very legit reason to ignore it , have a comment, DO NOT leave it blank. It's also generally a good idea to log the error message, so that we know that it happened.

Code Block
try {
  ....
} catch (SqoopException ok) {
  // its ok for me ignore this, since it is harmless
}

 

Few more guidelines Some conventions in Sqoop that you should follow!

  1. All unit test classes should be in the exact same package hierarchy as the source java class
  2. All unit test classes should begin

    with Test

    with Test for

    instance TestCSVInternmediateFormat

    instance TestCSVInternmediateFormat.java instead

    of CSVIntermediateFormatTest.

    of CSVIntermediateFormatTest. Integration tests apparently have FromRDBMSToHDFSTest.java format 

  3. If you see code duplicated, please create a JIRA and let us all know, we can collectively do the cleanup.

  4. Do not try to catch exceptions that you do not know how to handle, let it bubble up. 

  5. Try to use the IDE to clean-up unused imports

  6. Try not to create code with warnings. Especially when the IDE is screaming at you and telling you how to fix them!

  7. Goes without saying, do not have functions that run 100 lines long. break them down so it is easy to read and unit test

  8. Use Log.DEBUG / Log.INFO statements generously in code that is not easy to follow. It helps the person debugging your code!
  9. Use IDE for hashCode and equals and toString code generation. Use IDE for refactoring cues.
  10. Apache Kafka Coding Guide very beautifully documents some of the basic stuff of writing code. Kindly read it. 

        Few of our favorites are:

    •  Clear code is preferable to comments. When possible make your naming so good you don't need comments. When that isn't possible comments should be thought of as mandatory, write them to beread.
    •  Don't be sloppy. Don't check in commented out code: we use version control, it is still there in the history. Don't leave TODOs in the code or FIXMEs if you can help it. Don't leave println statements in the code. Hopefully this is all
  • obvious. Don
    •  obvious.  But if you still need to leave a TODO, create a ticket and then leave a TODO(SQOOP-1444), so we know what the details of the TODO are and who created it.
    •  Don't duplicate code (duh). Not even in tests.

 

 

...

    • Not even constants!
    • Logging, configuration, and public APIs are our "UI". Make them pretty, consistent, and usable.

Sqoopesque Conventions !

Dont ask me which coding standard/ style guide prescribes the following conventions, but it exists in Sqoop predating 1.99.4 and the committers follow this religiously!. So spend you time wisely ! Feel free to leave comments on additional things you notice that might sound very much Sqoopesque ( Conventions that are less prevalent outside of Sqoop)  

  • Enum classes, the semicolon needs to be in its own line. 
Code Block
public enum AuditLoggerError implements ErrorCode {
  /** An unknown error has occurred. */
  AUDIT_0000("An unknown error has occurred"),
  /** The system was unable to find or load the audit logger provider. */
  AUDIT_0001("The system was unable to find or load audit logger class"),
  /** The audit logger output file is not given. */
  AUDIT_0002("The output file for FileAuditLogger is not given"),
  ;

 

  • Also the Error codes have a format! Notice how they  Error codes are ordered in a specific classes.in the format ERROR_XXXX - four digits with leading zeros.
  • //todo

 

 

 

 

Before you get on to uploading the patch, also read this wiki that will help with getting through larger feature reviews quicker

...