当前位置: 首页>>代码示例>>Java>>正文


Java ImportAllTablesTool类代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:36,代码来源:TestAllTables.java

示例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();
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:29,代码来源:TestAllTables.java

示例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);
    }
  }
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:36,代码来源:TestAllTables.java

示例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);
    }
  }
}
 
开发者ID:infinidb,项目名称:sqoop,代码行数:36,代码来源:TestAllTables.java

示例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);
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:48,代码来源:TestAllTables.java

示例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);
    }
  }
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:48,代码来源:TestAllTables.java


注:本文中的com.cloudera.sqoop.tool.ImportAllTablesTool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。