com.cloudera.sqoop
Class SqoopOptions

java.lang.Object
  extended by com.cloudera.sqoop.SqoopOptions

public class SqoopOptions
extends java.lang.Object

Command-line arguments used by Sqoop.


Nested Class Summary
static class SqoopOptions.FileLayout
          Selects in-HDFS destination file format.
static class SqoopOptions.InvalidOptionsException
          Thrown when invalid cmdline options are given.
 
Field Summary
static int DEFAULT_NUM_MAPPERS
           
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
SqoopOptions()
           
SqoopOptions(org.apache.hadoop.conf.Configuration conf)
           
SqoopOptions(java.lang.String connect, java.lang.String table)
          Alternate SqoopOptions interface used mostly for unit testing.
 
Method Summary
 boolean doHiveImport()
           
 boolean doOverwriteHiveTable()
           
 boolean explicitDelims()
           
 java.lang.String getClassName()
           
 java.lang.String getCodeOutputDir()
           
 java.lang.String[] getColumns()
           
 org.apache.hadoop.conf.Configuration getConf()
           
 java.lang.String getConnectString()
           
 java.lang.String getDebugSqlCmd()
           
 long getDirectSplitSize()
           
 java.lang.String getDriverClassName()
           
 java.lang.String getExistingJarName()
           
 java.lang.String getExportDir()
           
 java.lang.String[] getExtraArgs()
           
 SqoopOptions.FileLayout getFileLayout()
           
 java.lang.String getHadoopHome()
          Return the value of $HADOOP_HOME.
 java.lang.String getHiveHome()
           
 java.lang.String getHiveTableName()
           
 long getInlineLobLimit()
           
 DelimiterSet getInputDelimiters()
           
 char getInputEnclosedBy()
           
 char getInputEscapedBy()
           
 char getInputFieldDelim()
           
 char getInputRecordDelim()
           
 java.lang.String getJarOutputDir()
           
 int getNumMappers()
           
 DelimiterSet getOutputDelimiters()
           
 char getOutputEnclosedBy()
           
 char getOutputEscapedBy()
           
 char getOutputFieldDelim()
           
 char getOutputRecordDelim()
           
 java.lang.String getPackageName()
           
 java.lang.String getPassword()
           
 java.lang.String getSplitByCol()
           
 java.lang.String getTableName()
           
 java.lang.String getTargetDir()
           
 java.lang.String getTempDir()
           
 java.lang.String getTmpDir()
          Get the temporary directory; guaranteed to end in File.separator (e.g., '/').
 java.lang.String getUsername()
           
 java.lang.String getWarehouseDir()
           
 java.lang.String getWhereClause()
           
 boolean isAppendMode()
           
 boolean isDirect()
           
 boolean isInputEncloseRequired()
           
 boolean isOutputEncloseRequired()
           
 void setAppendMode(boolean doAppend)
           
 void setClassName(java.lang.String name)
           
 void setCodeOutputDir(java.lang.String outputDir)
           
 void setColumns(java.lang.String[] cols)
           
 void setConf(org.apache.hadoop.conf.Configuration config)
           
 void setConnectString(java.lang.String connectStr)
           
 void setDebugSqlCmd(java.lang.String sqlStatement)
           
 void setDirectMode(boolean isDirect)
           
 void setDirectSplitSize(long splitSize)
           
 void setDriverClassName(java.lang.String driverClass)
           
 void setEnclosedBy(char c)
          Set the enclosed-by character to use when formatting lines.
 void setEscapedBy(char c)
          Set the escaped-by character to use when formatting lines.
 void setExistingJarName(java.lang.String jarFile)
           
 void setExplicitDelims(boolean explicit)
          Flag the delimiter settings as explicit user settings, or implicit.
 void setExportDir(java.lang.String dir)
           
 void setExtraArgs(java.lang.String[] args)
           
 void setFieldsTerminatedBy(char c)
          Set the field delimiter to use when formatting lines.
 void setFileLayout(SqoopOptions.FileLayout fileLayout)
           
 void setHadoopHome(java.lang.String home)
           
 void setHiveHome(java.lang.String home)
           
 void setHiveImport(boolean doImport)
           
 void setHiveTableName(java.lang.String name)
           
 void setInlineLobLimit(long limit)
           
 void setInputEnclosedBy(char c)
          Set the enclosed-by character to use when parsing lines.
 void setInputEncloseRequired(boolean required)
          If true, then all input fields are expected to be enclosed by the enclosed-by character when parsing.
 void setInputEscapedBy(char c)
          Set the escaped-by character to use when parsing lines.
 void setInputFieldsTerminatedBy(char c)
          Set the field delimiter to use when parsing lines.
 void setInputLinesTerminatedBy(char c)
          Set the record delimiter to use when parsing lines.
 void setJarOutputDir(java.lang.String outDir)
           
 void setLinesTerminatedBy(char c)
          Set the record delimiter to use when formatting lines.
 void setNumMappers(int m)
           
 void setOutputDelimiters(DelimiterSet delimiters)
          Set the complete set of delimiters to use for output formatting.
 void setOutputEncloseRequired(boolean required)
          If true, then the enclosed-by character will be applied to all fields, even if internal characters do not need enclosed-by protection.
 void setOverwriteHiveTable(boolean overwrite)
           
 void setPackageName(java.lang.String name)
           
 void setPassword(java.lang.String pass)
           
 void setPasswordFromConsole()
          Set the password in this SqoopOptions from the console without printing characters.
 void setSplitByCol(java.lang.String splitBy)
           
 void setTableName(java.lang.String table)
           
 void setTargetDir(java.lang.String dir)
           
 void setTmpDir(java.lang.String tmp)
           
 void setUseCompression(boolean compress)
           
 void setUsername(java.lang.String user)
           
 void setWarehouseDir(java.lang.String warehouse)
           
 void setWhereClause(java.lang.String where)
           
 boolean shouldUseCompression()
           
static char toChar(java.lang.String charish)
          Given a string containing a single character or an escape sequence representing a char, return that char itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

DEFAULT_NUM_MAPPERS

public static final int DEFAULT_NUM_MAPPERS
See Also:
Constant Field Values
Constructor Detail

SqoopOptions

public SqoopOptions()

SqoopOptions

public SqoopOptions(org.apache.hadoop.conf.Configuration conf)

SqoopOptions

public SqoopOptions(java.lang.String connect,
                    java.lang.String table)
Alternate SqoopOptions interface used mostly for unit testing.

Parameters:
connect - JDBC connect string to use
table - Table to read
Method Detail

getTempDir

public java.lang.String getTempDir()
Returns:
the temp directory to use; this is guaranteed to end with the file separator character (e.g., '/').

toChar

public static char toChar(java.lang.String charish)
                   throws SqoopOptions.InvalidOptionsException
Given a string containing a single character or an escape sequence representing a char, return that char itself. Normal literal characters return themselves: "x" -> 'x', etc. Strings containing a '\' followed by one of t, r, n, or b escape to the usual character as seen in Java: "\n" -> (newline), etc. Strings like "\0ooo" return the character specified by the octal sequence 'ooo'. Strings like "\0xhhh" or "\0Xhhh" return the character specified by the hex sequence 'hhh'. If the input string contains leading or trailing spaces, these are ignored.

Throws:
SqoopOptions.InvalidOptionsException

getTmpDir

public java.lang.String getTmpDir()
Get the temporary directory; guaranteed to end in File.separator (e.g., '/').


setTmpDir

public void setTmpDir(java.lang.String tmp)

getConnectString

public java.lang.String getConnectString()

setConnectString

public void setConnectString(java.lang.String connectStr)

getTableName

public java.lang.String getTableName()

setTableName

public void setTableName(java.lang.String table)

getExportDir

public java.lang.String getExportDir()

setExportDir

public void setExportDir(java.lang.String dir)

getExistingJarName

public java.lang.String getExistingJarName()

setExistingJarName

public void setExistingJarName(java.lang.String jarFile)

getColumns

public java.lang.String[] getColumns()

setColumns

public void setColumns(java.lang.String[] cols)

getSplitByCol

public java.lang.String getSplitByCol()

setSplitByCol

public void setSplitByCol(java.lang.String splitBy)

getWhereClause

public java.lang.String getWhereClause()

setWhereClause

public void setWhereClause(java.lang.String where)

getUsername

public java.lang.String getUsername()

setUsername

public void setUsername(java.lang.String user)

getPassword

public java.lang.String getPassword()

setPasswordFromConsole

public void setPasswordFromConsole()
Set the password in this SqoopOptions from the console without printing characters.


setPassword

public void setPassword(java.lang.String pass)

isDirect

public boolean isDirect()

setDirectMode

public void setDirectMode(boolean isDirect)

getNumMappers

public int getNumMappers()
Returns:
the number of map tasks to use for import.

setNumMappers

public void setNumMappers(int m)

getClassName

public java.lang.String getClassName()
Returns:
the user-specified absolute class name for the table.

setClassName

public void setClassName(java.lang.String name)

getPackageName

public java.lang.String getPackageName()
Returns:
the user-specified package to prepend to table names via --package-name.

setPackageName

public void setPackageName(java.lang.String name)

getHiveHome

public java.lang.String getHiveHome()

setHiveHome

public void setHiveHome(java.lang.String home)

doHiveImport

public boolean doHiveImport()
Returns:
true if we should import the table into Hive.

setHiveImport

public void setHiveImport(boolean doImport)

doOverwriteHiveTable

public boolean doOverwriteHiveTable()
Returns:
the user-specified option to overwrite existing table in hive.

setOverwriteHiveTable

public void setOverwriteHiveTable(boolean overwrite)

getCodeOutputDir

public java.lang.String getCodeOutputDir()
Returns:
location where .java files go; guaranteed to end with '/'.

setCodeOutputDir

public void setCodeOutputDir(java.lang.String outputDir)

getJarOutputDir

public java.lang.String getJarOutputDir()
Returns:
location where .jar and .class files go; guaranteed to end with '/'.

setJarOutputDir

public void setJarOutputDir(java.lang.String outDir)

getHadoopHome

public java.lang.String getHadoopHome()
Return the value of $HADOOP_HOME.

Returns:
$HADOOP_HOME, or null if it's not set.

setHadoopHome

public void setHadoopHome(java.lang.String home)

getDebugSqlCmd

public java.lang.String getDebugSqlCmd()
Returns:
a sql command to execute and exit with.

setDebugSqlCmd

public void setDebugSqlCmd(java.lang.String sqlStatement)

getDriverClassName

public java.lang.String getDriverClassName()
Returns:
The JDBC driver class name specified with --driver.

setDriverClassName

public void setDriverClassName(java.lang.String driverClass)

getWarehouseDir

public java.lang.String getWarehouseDir()
Returns:
the base destination path for table uploads.

setWarehouseDir

public void setWarehouseDir(java.lang.String warehouse)

getTargetDir

public java.lang.String getTargetDir()

setTargetDir

public void setTargetDir(java.lang.String dir)

setAppendMode

public void setAppendMode(boolean doAppend)

isAppendMode

public boolean isAppendMode()

getFileLayout

public SqoopOptions.FileLayout getFileLayout()
Returns:
the destination file format

setFileLayout

public void setFileLayout(SqoopOptions.FileLayout fileLayout)

getInputFieldDelim

public char getInputFieldDelim()
Returns:
the field delimiter to use when parsing lines. Defaults to the field delim to use when printing lines.

setInputFieldsTerminatedBy

public void setInputFieldsTerminatedBy(char c)
Set the field delimiter to use when parsing lines.


getInputRecordDelim

public char getInputRecordDelim()
Returns:
the record delimiter to use when parsing lines. Defaults to the record delim to use when printing lines.

setInputLinesTerminatedBy

public void setInputLinesTerminatedBy(char c)
Set the record delimiter to use when parsing lines.


getInputEnclosedBy

public char getInputEnclosedBy()
Returns:
the character that may enclose fields when parsing lines. Defaults to the enclosing-char to use when printing lines.

setInputEnclosedBy

public void setInputEnclosedBy(char c)
Set the enclosed-by character to use when parsing lines.


getInputEscapedBy

public char getInputEscapedBy()
Returns:
the escape character to use when parsing lines. Defaults to the escape character used when printing lines.

setInputEscapedBy

public void setInputEscapedBy(char c)
Set the escaped-by character to use when parsing lines.


isInputEncloseRequired

public boolean isInputEncloseRequired()
Returns:
true if fields must be enclosed by the --enclosed-by character when parsing. Defaults to false. Set true when --input-enclosed-by is used.

setInputEncloseRequired

public void setInputEncloseRequired(boolean required)
If true, then all input fields are expected to be enclosed by the enclosed-by character when parsing.


getOutputFieldDelim

public char getOutputFieldDelim()
Returns:
the character to print between fields when importing them to text.

setFieldsTerminatedBy

public void setFieldsTerminatedBy(char c)
Set the field delimiter to use when formatting lines.


getOutputRecordDelim

public char getOutputRecordDelim()
Returns:
the character to print between records when importing them to text.

setLinesTerminatedBy

public void setLinesTerminatedBy(char c)
Set the record delimiter to use when formatting lines.


getOutputEnclosedBy

public char getOutputEnclosedBy()
Returns:
a character which may enclose the contents of fields when imported to text.

setEnclosedBy

public void setEnclosedBy(char c)
Set the enclosed-by character to use when formatting lines.


getOutputEscapedBy

public char getOutputEscapedBy()
Returns:
a character which signifies an escape sequence when importing to text.

setEscapedBy

public void setEscapedBy(char c)
Set the escaped-by character to use when formatting lines.


isOutputEncloseRequired

public boolean isOutputEncloseRequired()
Returns:
true if fields imported to text must be enclosed by the EnclosedBy char. default is false; set to true if --enclosed-by is used instead of --optionally-enclosed-by.

setOutputEncloseRequired

public void setOutputEncloseRequired(boolean required)
If true, then the enclosed-by character will be applied to all fields, even if internal characters do not need enclosed-by protection.


getOutputDelimiters

public DelimiterSet getOutputDelimiters()
Returns:
the set of delimiters used for formatting output records.

setOutputDelimiters

public void setOutputDelimiters(DelimiterSet delimiters)
Set the complete set of delimiters to use for output formatting.


getInputDelimiters

public DelimiterSet getInputDelimiters()
Returns:
the set of delimiters used for parsing the input. This may include values implicitly set by the output delimiters.

shouldUseCompression

public boolean shouldUseCompression()
Returns:
true if the user wants imported results to be compressed.

setUseCompression

public void setUseCompression(boolean compress)

getHiveTableName

public java.lang.String getHiveTableName()
Returns:
the name of the destination table when importing to Hive.

setHiveTableName

public void setHiveTableName(java.lang.String name)

getDirectSplitSize

public long getDirectSplitSize()
Returns:
the file size to split by when using --direct mode.

setDirectSplitSize

public void setDirectSplitSize(long splitSize)

getInlineLobLimit

public long getInlineLobLimit()
Returns:
the max size of a LOB before we spill to a separate file.

setInlineLobLimit

public void setInlineLobLimit(long limit)

explicitDelims

public boolean explicitDelims()
Returns:
true if the delimiters have been explicitly set by the user.

setExplicitDelims

public void setExplicitDelims(boolean explicit)
Flag the delimiter settings as explicit user settings, or implicit.


getConf

public org.apache.hadoop.conf.Configuration getConf()

setConf

public void setConf(org.apache.hadoop.conf.Configuration config)

getExtraArgs

public java.lang.String[] getExtraArgs()
Returns:
command-line arguments after a '-'.

setExtraArgs

public void setExtraArgs(java.lang.String[] args)


Copyright © 2010 Cloudera, Inc.