本文整理匯總了Java中com.cloudera.sqoop.tool.ImportAllTablesTool類的典型用法代碼示例。如果您正苦於以下問題:Java ImportAllTablesTool類的具體用法?Java ImportAllTablesTool怎麽用?Java ImportAllTablesTool使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ImportAllTablesTool類屬於com.cloudera.sqoop.tool包,在下文中一共展示了ImportAllTablesTool類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMultiTableImport
import com.cloudera.sqoop.tool.ImportAllTablesTool; //導入依賴的package包/類
public void testMultiTableImport() throws IOException {
String [] argv = getArgv(null, null);
runImport(new ImportAllTablesTool(), argv);
Path warehousePath = new Path(this.getWarehouseDir());
int i = 0;
for (String tableName : this.tableNames) {
Path tablePath = new Path(warehousePath, tableName);
Path filePath = new Path(tablePath, "part-m-00000");
// dequeue the expected value for this table. This
// list has the same order as the tableNames list.
String expectedVal = Integer.toString(i++) + ","
+ this.expectedStrings.get(0);
this.expectedStrings.remove(0);
BufferedReader reader = null;
if (!isOnPhysicalCluster()) {
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File(filePath.toString()))));
} else {
FileSystem dfs = FileSystem.get(getConf());
FSDataInputStream dis = dfs.open(filePath);
reader = new BufferedReader(new InputStreamReader(dis));
}
try {
String line = reader.readLine();
assertEquals("Table " + tableName + " expected a different string",
expectedVal, line);
} finally {
IOUtils.closeStream(reader);
}
}
}
示例2: testMultiTableImportAsParquetFormat
import com.cloudera.sqoop.tool.ImportAllTablesTool; //導入依賴的package包/類
public void testMultiTableImportAsParquetFormat() throws IOException {
String [] argv = getArgv(new String[]{"--as-parquetfile"}, null);
runImport(new ImportAllTablesTool(), argv);
Path warehousePath = new Path(this.getWarehouseDir());
int i = 0;
for (String tableName : this.tableNames) {
Path tablePath = new Path(warehousePath, tableName);
Dataset dataset = Datasets.load("dataset:file:" + tablePath);
// dequeue the expected value for this table. This
// list has the same order as the tableNames list.
String expectedVal = Integer.toString(i++) + ","
+ this.expectedStrings.get(0);
this.expectedStrings.remove(0);
DatasetReader<GenericRecord> reader = dataset.newReader();
try {
GenericRecord record = reader.next();
String line = record.get(0) + "," + record.get(1);
assertEquals("Table " + tableName + " expected a different string",
expectedVal, line);
assertFalse(reader.hasNext());
} finally {
reader.close();
}
}
}
示例3: testMultiTableImport
import com.cloudera.sqoop.tool.ImportAllTablesTool; //導入依賴的package包/類
public void testMultiTableImport() throws IOException {
String [] argv = getArgv(true, null);
runImport(new ImportAllTablesTool(), argv);
Path warehousePath = new Path(this.getWarehouseDir());
int i = 0;
for (String tableName : this.tableNames) {
Path tablePath = new Path(warehousePath, tableName);
Path filePath = new Path(tablePath, "part-m-00000");
// dequeue the expected value for this table. This
// list has the same order as the tableNames list.
String expectedVal = Integer.toString(i++) + ","
+ this.expectedStrings.get(0);
this.expectedStrings.remove(0);
BufferedReader reader = null;
if (!isOnPhysicalCluster()) {
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File(filePath.toString()))));
} else {
FileSystem dfs = FileSystem.get(getConf());
FSDataInputStream dis = dfs.open(filePath);
reader = new BufferedReader(new InputStreamReader(dis));
}
try {
String line = reader.readLine();
assertEquals("Table " + tableName + " expected a different string",
expectedVal, line);
} finally {
IOUtils.closeStream(reader);
}
}
}
示例4: testMultiTableImport
import com.cloudera.sqoop.tool.ImportAllTablesTool; //導入依賴的package包/類
public void testMultiTableImport() throws IOException {
String [] argv = getArgv(true);
runImport(new ImportAllTablesTool(), argv);
Path warehousePath = new Path(this.getWarehouseDir());
int i = 0;
for (String tableName : this.tableNames) {
Path tablePath = new Path(warehousePath, tableName);
Path filePath = new Path(tablePath, "part-m-00000");
// dequeue the expected value for this table. This
// list has the same order as the tableNames list.
String expectedVal = Integer.toString(i++) + ","
+ this.expectedStrings.get(0);
this.expectedStrings.remove(0);
BufferedReader reader = null;
if (!isOnPhysicalCluster()) {
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File(filePath.toString()))));
} else {
FileSystem dfs = FileSystem.get(getConf());
FSDataInputStream dis = dfs.open(filePath);
reader = new BufferedReader(new InputStreamReader(dis));
}
try {
String line = reader.readLine();
assertEquals("Table " + tableName + " expected a different string",
expectedVal, line);
} finally {
IOUtils.closeStream(reader);
}
}
}
示例5: testMultiTableImportWithExclude
import com.cloudera.sqoop.tool.ImportAllTablesTool; //導入依賴的package包/類
public void testMultiTableImportWithExclude() throws IOException {
String exclude = this.tableNames.get(0);
String [] argv = getArgv(null, new String[]{ exclude });
runImport(new ImportAllTablesTool(), argv);
Path warehousePath = new Path(this.getWarehouseDir());
int i = 0;
for (String tableName : this.tableNames) {
Path tablePath = new Path(warehousePath, tableName);
Path filePath = new Path(tablePath, "part-m-00000");
// dequeue the expected value for this table. This
// list has the same order as the tableNames list.
String expectedVal = Integer.toString(i++) + ","
+ this.expectedStrings.get(0);
this.expectedStrings.remove(0);
BufferedReader reader = null;
if (!isOnPhysicalCluster()) {
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File(filePath.toString()))));
} else {
FSDataInputStream dis;
FileSystem dfs = FileSystem.get(getConf());
if (tableName.equals(exclude)) {
try {
dis = dfs.open(filePath);
assertFalse(true);
} catch (FileNotFoundException e) {
// Success
continue;
}
} else {
dis = dfs.open(filePath);
}
reader = new BufferedReader(new InputStreamReader(dis));
}
try {
String line = reader.readLine();
assertEquals("Table " + tableName + " expected a different string",
expectedVal, line);
} finally {
IOUtils.closeStream(reader);
}
}
}
示例6: testMultiTableImportWithExclude
import com.cloudera.sqoop.tool.ImportAllTablesTool; //導入依賴的package包/類
public void testMultiTableImportWithExclude() throws IOException {
String exclude = this.tableNames.get(0);
String [] argv = getArgv(true, new String[]{ exclude });
runImport(new ImportAllTablesTool(), argv);
Path warehousePath = new Path(this.getWarehouseDir());
int i = 0;
for (String tableName : this.tableNames) {
Path tablePath = new Path(warehousePath, tableName);
Path filePath = new Path(tablePath, "part-m-00000");
// dequeue the expected value for this table. This
// list has the same order as the tableNames list.
String expectedVal = Integer.toString(i++) + ","
+ this.expectedStrings.get(0);
this.expectedStrings.remove(0);
BufferedReader reader = null;
if (!isOnPhysicalCluster()) {
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File(filePath.toString()))));
} else {
FSDataInputStream dis;
FileSystem dfs = FileSystem.get(getConf());
if (tableName.equals(exclude)) {
try {
dis = dfs.open(filePath);
assertFalse(true);
} catch (FileNotFoundException e) {
// Success
continue;
}
} else {
dis = dfs.open(filePath);
}
reader = new BufferedReader(new InputStreamReader(dis));
}
try {
String line = reader.readLine();
assertEquals("Table " + tableName + " expected a different string",
expectedVal, line);
} finally {
IOUtils.closeStream(reader);
}
}
}