org.apache.hadoop.io.IOUtils.writeFully()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.apache.hadoop.io.IOUtils.writeFully()方法的一些代码示例,展示了IOUtils.writeFully()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.writeFully()方法的具体详情如下:
包路径:org.apache.hadoop.io.IOUtils
类名称:IOUtils
方法名:writeFully

IOUtils.writeFully介绍

[英]Write a ByteBuffer to a FileChannel at a given offset, handling short writes.
[中]以给定偏移量将ByteBuffer写入文件通道,处理短写操作。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

  1. public void set(long newVal) throws IOException {
  2. lazyOpen();
  3. buf.clear();
  4. buf.putLong(newVal);
  5. buf.flip();
  6. IOUtils.writeFully(ch, buf, 0);
  7. value = newVal;
  8. }

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

  1. private void preallocate() throws IOException {
  2. long position = fc.position();
  3. long size = fc.size();
  4. int bufSize = doubleBuf.getReadyBuf().getLength();
  5. long need = bufSize - (size - position);
  6. if (need <= 0) {
  7. return;
  8. }
  9. long oldSize = size;
  10. long total = 0;
  11. long fillCapacity = fill.capacity();
  12. while (need > 0) {
  13. fill.position(0);
  14. IOUtils.writeFully(fc, fill, size);
  15. need -= fillCapacity;
  16. size += fillCapacity;
  17. total += fillCapacity;
  18. }
  19. if(LOG.isDebugEnabled()) {
  20. LOG.debug("Preallocated " + total + " bytes at the end of " +
  21. "the edit log (offset " + oldSize + ")");
  22. }
  23. }

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

  1. public void set(long newVal) throws IOException {
  2. lazyOpen();
  3. buf.clear();
  4. buf.putLong(newVal);
  5. buf.flip();
  6. IOUtils.writeFully(ch, buf, 0);
  7. value = newVal;
  8. }

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

  1. public void set(long newVal) throws IOException {
  2. lazyOpen();
  3. buf.clear();
  4. buf.putLong(newVal);
  5. buf.flip();
  6. IOUtils.writeFully(ch, buf, 0);
  7. value = newVal;
  8. }

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

  1. private void preallocate() throws IOException {
  2. long position = fc.position();
  3. long size = fc.size();
  4. int bufSize = doubleBuf.getReadyBuf().getLength();
  5. long need = bufSize - (size - position);
  6. if (need <= 0) {
  7. return;
  8. }
  9. long oldSize = size;
  10. long total = 0;
  11. long fillCapacity = fill.capacity();
  12. while (need > 0) {
  13. fill.position(0);
  14. IOUtils.writeFully(fc, fill, size);
  15. need -= fillCapacity;
  16. size += fillCapacity;
  17. total += fillCapacity;
  18. }
  19. if(LOG.isDebugEnabled()) {
  20. LOG.debug("Preallocated " + total + " bytes at the end of " +
  21. "the edit log (offset " + oldSize + ")");
  22. }
  23. }

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

  1. private void preallocate() throws IOException {
  2. long position = fc.position();
  3. long size = fc.size();
  4. int bufSize = doubleBuf.getReadyBuf().getLength();
  5. long need = bufSize - (size - position);
  6. if (need <= 0) {
  7. return;
  8. }
  9. long oldSize = size;
  10. long total = 0;
  11. long fillCapacity = fill.capacity();
  12. while (need > 0) {
  13. fill.position(0);
  14. IOUtils.writeFully(fc, fill, size);
  15. need -= fillCapacity;
  16. size += fillCapacity;
  17. total += fillCapacity;
  18. }
  19. if(LOG.isDebugEnabled()) {
  20. LOG.debug("Preallocated " + total + " bytes at the end of " +
  21. "the edit log (offset " + oldSize + ")");
  22. }
  23. }

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

  1. FileChannel fc = raf.getChannel();
  2. ByteBuffer buf = ByteBuffer.wrap(input);
  3. IOUtils.writeFully(fc, buf);
  4. raf.seek(0);
  5. raf.read(output);
  6. IOUtils.writeFully(fc, buf, HALFWAY);
  7. for (int i = 0; i < HALFWAY; i++) {
  8. assertEquals(input[i], output[i]);

代码示例来源:origin: ch.cern.hadoop/hadoop-common

  1. FileChannel fc = raf.getChannel();
  2. ByteBuffer buf = ByteBuffer.wrap(input);
  3. IOUtils.writeFully(fc, buf);
  4. raf.seek(0);
  5. raf.read(output);
  6. IOUtils.writeFully(fc, buf, HALFWAY);
  7. for (int i = 0; i < HALFWAY; i++) {
  8. assertEquals(input[i], output[i]);

相关文章