gpt4 book ai didi

com.indeed.util.mmap.ZeroCopyOutputStream类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:23:04 28 4
gpt4 key购买 nike

本文整理了Java中com.indeed.util.mmap.ZeroCopyOutputStream类的一些代码示例,展示了ZeroCopyOutputStream类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroCopyOutputStream类的具体详情如下:
包路径:com.indeed.util.mmap.ZeroCopyOutputStream
类名称: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());
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com