本文整理汇总了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);
}
}
}