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

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

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

ByteBuf.hasArray介绍

[英]Returns true if and only if this buffer has a backing byte array. If this method returns true, you can safely call #array() and #arrayOffset().
[中]

代码示例

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

@Override
public boolean hasArray() {
  return buf.hasArray();
}

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

@Override
public boolean hasArray() {
  return buf.hasArray();
}

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

@Override
public boolean hasArray() {
  return unwrap().hasArray();
}

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

@Override
public boolean hasArray() {
  return unwrap().hasArray();
}

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

@Override
public boolean hasArray() {
  switch (components.size()) {
  case 0:
    return true;
  case 1:
    return components.get(0).buf.hasArray();
  default:
    return false;
  }
}

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

@Override
public boolean hasArray() {
  switch (components.size()) {
  case 0:
    return true;
  case 1:
    return components.get(0).buf.hasArray();
  default:
    return false;
  }
}

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

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

/**
 * @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

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

相关文章