當前位置: 首頁>>代碼示例>>Java>>正文


Java FSDataInputStream.available方法代碼示例

本文整理匯總了Java中org.apache.hadoop.fs.FSDataInputStream.available方法的典型用法代碼示例。如果您正苦於以下問題:Java FSDataInputStream.available方法的具體用法?Java FSDataInputStream.available怎麽用?Java FSDataInputStream.available使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.fs.FSDataInputStream的用法示例。


在下文中一共展示了FSDataInputStream.available方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: download

import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
/**
 * 從hadoop中下載文件
 *
 * @param taskName
 * @param filePath
 */
public static void download(String taskName, String filePath, boolean existDelete) {
    File file = new File(filePath);
    if (file.exists()) {
        if (existDelete) {
            file.deleteOnExit();
        } else {
            return;
        }
    }
    String hadoopAddress = propertyConfig.getProperty("sqoop.task." + taskName + ".tolink.linkConfig.uri");
    String itemmodels = propertyConfig.getProperty("sqoop.task." + taskName + ".recommend.itemmodels");
    try {
        DistributedFileSystem distributedFileSystem = distributedFileSystem(hadoopAddress);
        FSDataInputStream fsDataInputStream = distributedFileSystem.open(new Path(itemmodels));
        byte[] bs = new byte[fsDataInputStream.available()];
        fsDataInputStream.read(bs);
        log.info(new String(bs));

        FileOutputStream fileOutputStream = new FileOutputStream(new File(filePath));
        IOUtils.write(bs, fileOutputStream);
        IOUtils.closeQuietly(fileOutputStream);
    } catch (IOException e) {
        log.error(e);
    }
}
 
開發者ID:babymm,項目名稱:mmsns,代碼行數:32,代碼來源:HadoopUtil.java

示例2: print

import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
/**
 * 查看輸出結果
 *
 * @param path
 */
public void print(String path) {
    log.info("mapreduce輸出結果:...................................................");
    DistributedFileSystem distributedFileSystem = distributedFileSystem();
    try {
        FileStatus[] fileStatuses = distributedFileSystem.listStatus(new Path(path));
        for (FileStatus fs : fileStatuses) {
            log.info(fs);
            FSDataInputStream fsDataInputStream = distributedFileSystem.open(fs.getPath());
            byte[] bs = new byte[fsDataInputStream.available()];
            fsDataInputStream.read(bs);
            log.info("\n" + new String(bs) + "\n");
        }
    } catch (IOException e) {
        log.error(e);
    } finally {
        close(distributedFileSystem);
    }
}
 
開發者ID:mumuhadoop,項目名稱:mumu-mapreduce,代碼行數:24,代碼來源:MapReduceConfiguration.java

示例3: printMessage

import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
public void printMessage(String path) {
    System.out.println("\nprint result:");
    DistributedFileSystem distributedFileSystem = distributedFileSystem();
    try {
        FileStatus[] fileStatuses = distributedFileSystem.listStatus(new Path(path));
        for (FileStatus fileStatus : fileStatuses) {
            System.out.println(fileStatus);
            if (fileStatus.isFile()) {
                FSDataInputStream fsDataInputStream = distributedFileSystem.open(fileStatus.getPath());
                byte[] bs = new byte[fsDataInputStream.available()];
                fsDataInputStream.read(bs);
                fsDataInputStream.close();
                System.out.println(new String(bs));
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        close(distributedFileSystem);
    }
}
 
開發者ID:mumuhadoop,項目名稱:mumu-pig,代碼行數:22,代碼來源:MumuPigConfiguration.java

示例4: deserialize

import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
/**
 * read matrix meta protos from input stream
 * @param input input stream
 * @throws IOException, InvalidParameterException
 */
public void deserialize(FSDataInputStream input)
  throws IOException, InvalidParameterException, ClassNotFoundException {
  while(input.available() > 0) {
    MatrixMeta meta = ProtobufUtil.convertToMatrixMeta(ProtobufUtil.loadMatrixMetaProto(input));
    matrixMetaManager.addMatrix(meta);
    try {
      writeLock.lock();
      buildPSMatrixMeta(meta);
    } finally {
      writeLock.unlock();
    }
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:19,代碼來源:AMMatrixMetaManager.java

示例5: readFile

import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
private static byte [] readFile(final FileSystem fs, final Path path) throws IOException {
  FSDataInputStream tmpIn = fs.open(path);
  try {
    byte [] rawData = new byte[tmpIn.available()];
    tmpIn.readFully(rawData);
    return rawData;
  } finally {
    tmpIn.close();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:11,代碼來源:RegionSplitter.java


注:本文中的org.apache.hadoop.fs.FSDataInputStream.available方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。