本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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");
}
}
示例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();
}
}
示例9: getOutputStream
import com.google.common.io.NullOutputStream; //导入依赖的package包/类
public OutputStream getOutputStream() {
return new NullOutputStream();
}