本文整理汇总了Java中org.apache.solr.update.MemOutputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java MemOutputStream.close方法的具体用法?Java MemOutputStream.close怎么用?Java MemOutputStream.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.update.MemOutputStream
的用法示例。
在下文中一共展示了MemOutputStream.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRandomWrites
import org.apache.solr.update.MemOutputStream; //导入方法依赖的package包/类
public void doRandomWrites() throws Exception {
int bufSize = ( rand.nextBoolean() ? rand.nextInt(10) : rand.nextInt(20000) )+1;
MemOutputStream out = new MemOutputStream(new byte[bufSize]);
int hash = 0;
long written = 0;
int iter = rand.nextInt(10)+1;
for (int i=0; i<iter; i++) {
int off = rand.nextInt(arr.length);
int len = off < arr.length ? rand.nextInt(arr.length - off) : 0;
out.write(arr, off, len);
hash = incHash(hash, arr, off, len);
written += len;
int pos = rand.nextInt(arr.length);
out.write(arr[pos]);
hash = incHash(hash, arr, pos, 1);
written += 1;
}
out.close();
int hash2 = 0;
for (byte[] buffer : out.buffers) {
hash2 = incHash(hash2, buffer, 0, buffer.length);
}
assertEquals(hash, hash2);
assertEquals(written, out.written());
assertEquals(written, out.size());
}