本文整理了Java中com.indeed.util.mmap.ZeroCopyOutputStream
类的一些代码示例,展示了ZeroCopyOutputStream
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroCopyOutputStream
类的具体详情如下:
包路径:com.indeed.util.mmap.ZeroCopyOutputStream
类名称:ZeroCopyOutputStream
[英]Zero Copy is sort of a lie, it's zero copy if realloc decides not to copy for sizes less than MMAP_THRESHOLD (default 256 k) and then after that it's totally zero copy
[中]零拷贝是一种谎言,如果realloc决定不拷贝小于MMAP_阈值(默认256 k)的大小,那么零拷贝就是零拷贝,然后在这之后它就完全是零拷贝了
代码示例来源:origin: indeedeng/util
public void writeTo(OutputStream outputStream) throws IOException {
final MemoryInputStream in = new MemoryInputStream(memory());
ByteStreams.copy(in, outputStream);
}
代码示例来源:origin: indeedeng/util
public void write(final int b) throws IOException {
writeByte(b);
}
代码示例来源:origin: indeedeng/imhotep
final ZeroCopyOutputStream valuesFileOut = new ZeroCopyOutputStream();
final CountingOutputStream counter = new CountingOutputStream(new BufferedOutputStream(valuesFileOut));
final LittleEndianDataOutputStream valuesOut = closer.register(new LittleEndianDataOutputStream(counter));
final NativeBuffer buffer = valuesFileOut.getBuffer().realloc(valuesFileOut.position());
return Pair.of(offsets, buffer);
} catch (Throwable t) {
代码示例来源:origin: indeedeng/util
@Override
public void write(final byte[] b, final int off, final int len) throws IOException {
if (off < 0 || len < 0 || off+len > b.length) {
throw new IndexOutOfBoundsException();
}
if (currentAddress + len > memory.length()) {
buffer = buffer.realloc(memory.length()*2);
memory = buffer.memory();
write(b, off, len);
} else {
memory.putBytes(currentAddress, b, off, len);
currentAddress+=len;
}
}
代码示例来源:origin: indeedeng/util
public void writeChar(final int v) throws IOException {
if (currentAddress + 2 > memory.length()) {
buffer = buffer.realloc(memory.length()*2);
memory = buffer.memory();
writeChar(v);
} else {
memory.putChar(currentAddress, (char)v);
currentAddress+=2;
}
}
代码示例来源:origin: indeedeng/util
public void writeFloat(final float v) throws IOException {
if (currentAddress + 4 > memory.length()) {
buffer = buffer.realloc(memory.length()*2);
memory = buffer.memory();
writeFloat(v);
} else {
memory.putFloat(currentAddress, v);
currentAddress+=4;
}
}
代码示例来源:origin: indeedeng/util
public void writeBoolean(final boolean v) throws IOException {
if (currentAddress + 1 > memory.length()) {
buffer = buffer.realloc(memory.length()*2);
memory = buffer.memory();
writeBoolean(v);
} else {
memory.putByte(currentAddress, (byte)(v ? 1 : 0));
currentAddress++;
}
}
代码示例来源:origin: indeedeng/util
public void writeDouble(final double v) throws IOException {
if (currentAddress + 8 > memory.length()) {
buffer = buffer.realloc(memory.length()*2);
memory = buffer.memory();
writeDouble(v);
} else {
memory.putDouble(currentAddress, v);
currentAddress+=8;
}
}
代码示例来源:origin: indeedeng/util
public void writeByte(final int v) throws IOException {
if (currentAddress + 1 > memory.length()) {
buffer = buffer.realloc(memory.length()*2);
memory = buffer.memory();
writeByte(v);
} else {
memory.putByte(currentAddress, (byte)v);
currentAddress++;
}
}
代码示例来源:origin: indeedeng/util
public InputStream getInputStream() {
return new MemoryInputStream(memory());
}
内容来源于网络,如有侵权,请联系作者删除!