當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。