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

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

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

ByteBuf.arrayOffset介绍

[英]Returns the offset of the first byte within the backing byte array of this buffer.
[中]返回此缓冲区的备份字节数组中第一个字节的偏移量。

代码示例

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

@Override
public int arrayOffset() {
  return unwrap().arrayOffset();
}

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

@Override
public int arrayOffset() {
  switch (components.size()) {
  case 0:
    return 0;
  case 1:
    return components.get(0).buf.arrayOffset();
  default:
    throw new UnsupportedOperationException();
  }
}

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

@Override
public int arrayOffset() {
  switch (components.size()) {
  case 0:
    return 0;
  case 1:
    return components.get(0).buf.arrayOffset();
  default:
    throw new UnsupportedOperationException();
  }
}

代码示例来源: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: 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: 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: 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

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: 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: couchbase/couchbase-jvm-core

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 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: 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: couchbase/couchbase-jvm-core

@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 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: 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: 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;
}

代码示例来源: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;
}

相关文章