com.couchbase.client.deps.io.netty.buffer.ByteBuf.array()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中com.couchbase.client.deps.io.netty.buffer.ByteBuf.array()方法的一些代码示例,展示了ByteBuf.array()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.array()方法的具体详情如下:
包路径:com.couchbase.client.deps.io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:array

ByteBuf.array介绍

[英]Returns the backing byte array of this buffer.
[中]返回此缓冲区的后备字节数组。

代码示例

代码示例来源:origin: com.couchbase.client/core-io

@Override
public byte[] array() {
  return buf.array();
}

代码示例来源:origin: com.couchbase.client/core-io

/**
 * @param buffer buffer with a backing byte array
 */
SeekAheadOptimize(ByteBuf buffer) {
  if (!buffer.hasArray()) {
    throw new IllegalArgumentException("buffer hasn't backing byte array");
  }
  this.buffer = buffer;
  bytes = buffer.array();
  readerIndex = buffer.readerIndex();
  origPos = pos = buffer.arrayOffset() + readerIndex;
  limit = buffer.arrayOffset() + buffer.writerIndex();
}

代码示例来源:origin: com.couchbase.client/core-io

private void deflate(ByteBuf out) {
  int numBytes;
  do {
    int writerIndex = out.writerIndex();
    numBytes = deflater.deflate(
        out.array(), out.arrayOffset() + writerIndex, out.writableBytes(), Deflater.SYNC_FLUSH);
    out.writerIndex(writerIndex + numBytes);
  } while (numBytes > 0);
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public byte[] array() {
  switch (components.size()) {
  case 0:
    return EmptyArrays.EMPTY_BYTES;
  case 1:
    return components.get(0).buf.array();
  default:
    throw new UnsupportedOperationException();
  }
}

代码示例来源:origin: couchbase/couchbase-jvm-core

private void deflate(ByteBuf out) {
  int numBytes;
  do {
    int writerIndex = out.writerIndex();
    numBytes = deflater.deflate(
        out.array(), out.arrayOffset() + writerIndex, out.writableBytes(), Deflater.SYNC_FLUSH);
    out.writerIndex(writerIndex + numBytes);
  } while (numBytes > 0);
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public byte[] array() {
  switch (components.size()) {
  case 0:
    return EmptyArrays.EMPTY_BYTES;
  case 1:
    return components.get(0).buf.array();
  default:
    throw new UnsupportedOperationException();
  }
}

代码示例来源:origin: com.couchbase.client/core-io

private boolean compressInto(ByteBuf compressed) {
  byte[] out = compressed.array();
  int off = compressed.arrayOffset() + compressed.writerIndex();
  int toWrite = compressed.writableBytes();
  int numBytes = compressor.deflate(out, off, toWrite, Deflater.SYNC_FLUSH);
  compressed.writerIndex(compressed.writerIndex() + numBytes);
  return numBytes == toWrite;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public byte[] get() {
  if (byteBuf == null) {
    return EMPTY_BUFFER.array();
  }
  byte[] array = new byte[byteBuf.readableBytes()];
  byteBuf.getBytes(byteBuf.readerIndex(), array);
  return array;
}

代码示例来源:origin: com.couchbase.client/core-io

private int setInput(ByteBuf compressed) {
  int len = compressed.readableBytes();
  if (compressed.hasArray()) {
    decompressor.setInput(compressed.array(), compressed.arrayOffset() + compressed.readerIndex(), len);
  } else {
    byte[] in = new byte[len];
    compressed.getBytes(compressed.readerIndex(), in);
    decompressor.setInput(in, 0, in.length);
  }
  return len;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public byte[] get() {
  if (byteBuf == null) {
    return EMPTY_BUFFER.array();
  }
  byte[] array = new byte[byteBuf.readableBytes()];
  byteBuf.getBytes(byteBuf.readerIndex(), array);
  return array;
}

代码示例来源:origin: com.couchbase.client/core-io

private int setInput(ByteBuf decompressed) {
  int len = decompressed.readableBytes();
  if (decompressed.hasArray()) {
    compressor.setInput(decompressed.array(), decompressed.arrayOffset() + decompressed.readerIndex(), len);
  } else {
    byte[] in = new byte[len];
    decompressed.getBytes(decompressed.readerIndex(), in);
    compressor.setInput(in, 0, in.length);
  }
  return len;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

private int setInput(ByteBuf compressed) {
  int len = compressed.readableBytes();
  if (compressed.hasArray()) {
    decompressor.setInput(compressed.array(), compressed.arrayOffset() + compressed.readerIndex(), len);
  } else {
    byte[] in = new byte[len];
    compressed.getBytes(compressed.readerIndex(), in);
    decompressor.setInput(in, 0, in.length);
  }
  return len;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

private int setInput(ByteBuf decompressed) {
  int len = decompressed.readableBytes();
  if (decompressed.hasArray()) {
    compressor.setInput(decompressed.array(), decompressed.arrayOffset() + decompressed.readerIndex(), len);
  } else {
    byte[] in = new byte[len];
    decompressed.getBytes(decompressed.readerIndex(), in);
    compressor.setInput(in, 0, in.length);
  }
  return len;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
  checkSrcIndex(index, length, srcIndex, src.capacity());
  if (src.hasMemoryAddress()) {
    PlatformDependent.copyMemory(src.memoryAddress() + srcIndex, array, index, length);
  } else  if (src.hasArray()) {
    setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
  } else {
    src.getBytes(srcIndex, array, index, length);
  }
  return this;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
  checkDstIndex(index, length, dstIndex, dst.capacity());
  if (dst.hasMemoryAddress()) {
    PlatformDependent.copyMemory(array, index, dst.memoryAddress() + dstIndex, length);
  } else if (dst.hasArray()) {
    getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
  } else {
    dst.setBytes(dstIndex, array, index, length);
  }
  return this;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
  checkSrcIndex(index, length, srcIndex, src.capacity());
  if (src.hasMemoryAddress()) {
    PlatformDependent.copyMemory(src.memoryAddress() + srcIndex, array, index, length);
  } else  if (src.hasArray()) {
    setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
  } else {
    src.getBytes(srcIndex, array, index, length);
  }
  return this;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public final ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
  checkSrcIndex(index, length, srcIndex, src.capacity());
  if (src.hasMemoryAddress()) {
    PlatformDependent.copyMemory(src.memoryAddress() + srcIndex, memory, idx(index), length);
  } else if (src.hasArray()) {
    setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
  } else {
    src.getBytes(srcIndex, memory, idx(index), length);
  }
  return this;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public final ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
  checkDstIndex(index, length, dstIndex, dst.capacity());
  if (dst.hasMemoryAddress()) {
    PlatformDependent.copyMemory(memory, idx(index), dst.memoryAddress() + dstIndex, length);
  } else if (dst.hasArray()) {
    getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
  } else {
    dst.setBytes(dstIndex, memory, idx(index), length);
  }
  return this;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public final ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
  checkDstIndex(index, length, dstIndex, dst.capacity());
  if (dst.hasMemoryAddress()) {
    PlatformDependent.copyMemory(memory, idx(index), dst.memoryAddress() + dstIndex, length);
  } else if (dst.hasArray()) {
    getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
  } else {
    dst.setBytes(dstIndex, memory, idx(index), length);
  }
  return this;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public final ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
  checkSrcIndex(index, length, srcIndex, src.capacity());
  if (src.hasMemoryAddress()) {
    PlatformDependent.copyMemory(src.memoryAddress() + srcIndex, memory, idx(index), length);
  } else if (src.hasArray()) {
    setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
  } else {
    src.getBytes(srcIndex, memory, idx(index), length);
  }
  return this;
}

相关文章