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


Java NullOutputStream类代码示例

本文整理汇总了Java中com.google.common.io.NullOutputStream的典型用法代码示例。如果您正苦于以下问题:Java NullOutputStream类的具体用法?Java NullOutputStream怎么用?Java NullOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NullOutputStream类属于com.google.common.io包,在下文中一共展示了NullOutputStream类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeTrailerSizeByVersion

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
private static int[] computeTrailerSizeByVersion() {
  int versionToSize[] = new int[HFile.MAX_FORMAT_VERSION + 1];
  for (int version = MIN_FORMAT_VERSION;
       version <= MAX_FORMAT_VERSION;
       ++version) {
    FixedFileTrailer fft = new FixedFileTrailer(version, 
                                 HFileBlock.MINOR_VERSION_NO_CHECKSUM);
    DataOutputStream dos = new DataOutputStream(new NullOutputStream());
    try {
      fft.serialize(dos);
    } catch (IOException ex) {
      // The above has no reason to fail.
      throw new RuntimeException(ex);
    }
    versionToSize[version] = dos.size();
  }
  return versionToSize;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:19,代码来源:FixedFileTrailer.java

示例2: computeTrailerSizeByVersion

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
private static int[] computeTrailerSizeByVersion() {
  int versionToSize[] = new int[HFile.MAX_FORMAT_VERSION + 1];
  for (int version = MIN_FORMAT_VERSION;
       version <= MAX_FORMAT_VERSION;
       ++version) {
    FixedFileTrailer fft = new FixedFileTrailer(version);
    DataOutputStream dos = new DataOutputStream(new NullOutputStream());
    try {
      fft.serialize(dos);
    } catch (IOException ex) {
      // The above has no reason to fail.
      throw new RuntimeException(ex);
    }
    versionToSize[version] = dos.size();
  }
  return versionToSize;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:18,代码来源:FixedFileTrailer.java

示例3: computeTrailerSizeByVersion

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
private static int[] computeTrailerSizeByVersion() {
  int versionToSize[] = new int[HFile.MAX_FORMAT_VERSION + 1];
  for (int version = HFile.MIN_FORMAT_VERSION;
       version <= HFile.MAX_FORMAT_VERSION;
       ++version) {
    FixedFileTrailer fft = new FixedFileTrailer(version, HFileBlock.MINOR_VERSION_NO_CHECKSUM);
    DataOutputStream dos = new DataOutputStream(new NullOutputStream());
    try {
      fft.serialize(dos);
    } catch (IOException ex) {
      // The above has no reason to fail.
      throw new RuntimeException(ex);
    }
    versionToSize[version] = dos.size();
  }
  return versionToSize;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:18,代码来源:FixedFileTrailer.java

示例4: getCompressedSize

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
/**
 * Find the size of compressed data assuming that buffer will be compressed
 * using given algorithm.
 * @param algo compression algorithm
 * @param compressor compressor already requested from codec
 * @param inputBuffer Array to be compressed.
 * @param offset Offset to beginning of the data.
 * @param length Length to be compressed.
 * @return Size of compressed data in bytes.
 * @throws IOException
 */
public static int getCompressedSize(Algorithm algo, Compressor compressor,
    byte[] inputBuffer, int offset, int length) throws IOException {
  DataOutputStream compressedStream = new DataOutputStream(
      new NullOutputStream());
  if (compressor != null) {
    compressor.reset();
  }
  OutputStream compressingStream = algo.createCompressionStream(
      compressedStream, compressor, 0);

  compressingStream.write(inputBuffer, offset, length);
  compressingStream.flush();
  compressingStream.close();

  return compressedStream.size();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:28,代码来源:EncodedDataBlock.java

示例5: testManyClosedSocketsInCache

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
@Test(timeout=30000)
public void testManyClosedSocketsInCache() throws Exception {
  // Make a small file
  Configuration clientConf = new Configuration(conf);
  clientConf.set(DFS_CLIENT_CONTEXT, "testManyClosedSocketsInCache");
  DistributedFileSystem fs =
      (DistributedFileSystem)FileSystem.get(cluster.getURI(),
          clientConf);
  PeerCache peerCache = ClientContext.getFromConf(clientConf).getPeerCache();
  DFSTestUtil.createFile(fs, TEST_FILE, 1L, (short)1, 0L);

  // Insert a bunch of dead sockets in the cache, by opening
  // many streams concurrently, reading all of the data,
  // and then closing them.
  InputStream[] stms = new InputStream[5];
  try {
    for (int i = 0; i < stms.length; i++) {
      stms[i] = fs.open(TEST_FILE);
    }
    for (InputStream stm : stms) {
      IOUtils.copyBytes(stm, new NullOutputStream(), 1024);
    }
  } finally {
    IOUtils.cleanup(null, stms);
  }
  
  assertEquals(5, peerCache.size());
  
  // Let all the xceivers timeout
  Thread.sleep(1500);
  assertXceiverCount(0);

  // Client side still has the sockets cached
  assertEquals(5, peerCache.size());

  // Reading should not throw an exception.
  DFSTestUtil.readFile(fs, TEST_FILE);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:39,代码来源:TestDataTransferKeepalive.java

示例6: testManyClosedSocketsInCache

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
@Test(timeout=30000)
public void testManyClosedSocketsInCache() throws Exception {
  // Make a small file
  DFSTestUtil.createFile(fs, TEST_FILE, 1L, (short)1, 0L);

  // Insert a bunch of dead sockets in the cache, by opening
  // many streams concurrently, reading all of the data,
  // and then closing them.
  InputStream[] stms = new InputStream[5];
  try {
    for (int i = 0; i < stms.length; i++) {
      stms[i] = fs.open(TEST_FILE);
    }
    for (InputStream stm : stms) {
      IOUtils.copyBytes(stm, new NullOutputStream(), 1024);
    }
  } finally {
    IOUtils.cleanup(null, stms);
  }
  
  DFSClient client = ((DistributedFileSystem)fs).dfs;
  assertEquals(5, client.peerCache.size());
  
  // Let all the xceivers timeout
  Thread.sleep(1500);
  assertXceiverCount(0);

  // Client side still has the sockets cached
  assertEquals(5, client.peerCache.size());

  // Reading should not throw an exception.
  DFSTestUtil.readFile(fs, TEST_FILE);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:34,代码来源:TestDataTransferKeepalive.java

示例7: testResultRowNumWhenSelectingOnPartitionedTable

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
@Test
public void testResultRowNumWhenSelectingOnPartitionedTable() throws Exception {
  try (TajoCli cli2 = new TajoCli(cluster.getConfiguration(), new String[]{}, null, System.in,
      new NullOutputStream(), new NullOutputStream())) {
    cli2.executeScript("create table region_part (r_regionkey int8, r_name text) " +
        "partition by column (r_comment text) as select * from region");

    setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
    tajoCli.executeScript("select r_comment from region_part where r_comment = 'hs use ironic, even requests. s'");
    String consoleResult = new String(out.toByteArray());
    assertOutputResult(consoleResult);
  } finally {
    tajoCli.executeScript("drop table region_part purge");
  }
}
 
开发者ID:apache,项目名称:tajo,代码行数:16,代码来源:TestTajoCli.java

示例8: OutputRedirector

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
public OutputRedirector(InputStream inputStream, OutputStream outputStream) {
	this.inputStream = new BufferedInputStream(inputStream);

	if (outputStream != null) {
		this.outputStream = outputStream;
	} else {
		this.outputStream = new NullOutputStream();
	}
}
 
开发者ID:atsid,项目名称:accumulo-mojo,代码行数:10,代码来源:AbstractServerTestRunner.java

示例9: getOutputStream

import com.google.common.io.NullOutputStream; //导入依赖的package包/类
public OutputStream getOutputStream() {
	return new NullOutputStream();
}
 
开发者ID:jenkinsci,项目名称:openshift-deployer-plugin,代码行数:4,代码来源:Logger.java


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