net.openhft.chronicle.bytes.Bytes.capacity()方法的使用及代码示例

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

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

Bytes.capacity介绍

暂无

代码示例

代码示例来源:origin: OpenHFT/Chronicle-Queue

@NotNull
private Wire readAnywhere(@NotNull Wire wire) {
  Bytes<?> bytes = wire.bytes();
  bytes.readLimit(bytes.capacity());
  return wire;
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

if (position > bytes.capacity())
  throw new IllegalArgumentException("pos: " + position);
if (secondaryAddress > bytes.capacity())
  throw new IllegalStateException("sa2: " + secondaryAddress);
bytes.readLimit(bytes.capacity());
LongArrayValues indexValues = arrayForAddress(wire, secondaryAddress);
int index3 = (int) ((sequenceNumber >>> indexSpacingBits) & (indexCount - 1));

代码示例来源:origin: OpenHFT/Chronicle-Queue

private void inACycleFound(Bytes<?> bytes) {
  context.closeReadLimit(bytes.capacity());
  wire().readAndSetLength(bytes.readPosition());
  long end = bytes.readLimit();
  context.closeReadPosition(end);
  Jvm.optionalSafepoint();
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

private boolean inACycle(boolean includeMetaData)
    throws EOFException {
  Jvm.optionalSafepoint();
  if (readAfterReplicaAcknowledged && inACycleCheckRep()) return false;
  Jvm.optionalSafepoint();
  if (direction != TailerDirection.FORWARD && !inACycleNotForward()) return false;
  Jvm.optionalSafepoint();
  Wire wire = wire();
  Bytes<?> bytes = wire.bytes();
  bytes.readLimit(bytes.capacity());
  switch (wire.readDataHeader(includeMetaData)) {
    case NONE:
      Jvm.optionalSafepoint();
      // no more polling - appender will always write (or recover) EOF
      return false;
    case META_DATA:
      Jvm.optionalSafepoint();
      context.metaData(true);
      break;
    case DATA:
      Jvm.optionalSafepoint();
      context.metaData(false);
      break;
  }
  Jvm.optionalSafepoint();
  inACycleFound(bytes);
  Jvm.optionalSafepoint();
  return true;
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

private void removeEOF(Path path) throws IOException {
  long blockSize = 64 << 10;
  long chunkSize = OS.pageAlign(blockSize);
  long overlapSize = OS.pageAlign(blockSize / 4);
  final MappedBytes mappedBytes = MappedBytes.mappedBytes(path.toFile(), chunkSize, overlapSize, false);
  mappedBytes.reserve();
  try {
    final Wire wire = WireType.BINARY_LIGHT.apply(mappedBytes);
    final Bytes<?> bytes = wire.bytes();
    bytes.readLimit(bytes.capacity());
    bytes.readSkip(4);
    // move past header
    try (final SingleChronicleQueueStore qs = loadStore(wire)) {
      assertNotNull(qs);
      long l = qs.writePosition();
      long len = Wires.lengthOf(bytes.readVolatileInt(l));
      long eofOffset = l + len + 4L;
      bytes.writePosition(eofOffset);
      bytes.writeInt(0);
    }
  } finally {
    mappedBytes.release();
  }
}

代码示例来源:origin: net.openhft/chronicle-bytes

/**
 * grow the buffer if the buffer is elastic, if the buffer is not elastic and there is not
 * enough capacity then this method will throws {@link java.nio.BufferOverflowException}
 *
 * @param size the capacity that you required
 * @throws IllegalArgumentException if the buffer is not elastic and there is not enough space
 */
default void ensureCapacity(long size) throws IllegalArgumentException {
  if (size > capacity())
    throw new IllegalArgumentException(isElastic() ? "todo" : "not elastic");
}

代码示例来源:origin: net.openhft/chronicle-map

public Bytes segmentBytesForRead() {
  segmentBytes.readLimit(segmentBytes.capacity());
  return segmentBytes;
}

代码示例来源:origin: net.openhft/chronicle-map

public Bytes segmentBytesForRead() {
  segmentBytes.readLimit(segmentBytes.capacity());
  return segmentBytes;
}

代码示例来源:origin: net.openhft/chronicle-map

public Bytes segmentBytesForRead() {
  segmentBytes.readLimit(segmentBytes.capacity());
  return segmentBytes;
}

代码示例来源:origin: net.openhft/chronicle-map

public Bytes segmentBytesForRead() {
  segmentBytes.readLimit(segmentBytes.capacity());
  return segmentBytes;
}

代码示例来源:origin: net.openhft/chronicle-queue

@NotNull
private Wire readAnywhere(@NotNull Wire wire) {
  Bytes<?> bytes = wire.bytes();
  bytes.readLimit(bytes.capacity());
  return wire;
}

代码示例来源:origin: net.openhft/chronicle-map

@Stage("Segment")
public Bytes segmentBytesForRead() {
  segmentBytes.readLimit(segmentBytes.capacity());
  return segmentBytes;
}

代码示例来源:origin: net.openhft/chronicle-bytes

/**
 * @return is the readPosition at the start and the writeLimit at the end.
 */
@Override
default boolean isClear() {
  return start() == readPosition() && writeLimit() == capacity();
}

代码示例来源:origin: net.openhft/chronicle-queue

if (position > bytes.capacity())
  throw new IllegalArgumentException("pos: " + position);
if (secondaryAddress > bytes.capacity())
  throw new IllegalStateException("sa2: " + secondaryAddress);
bytes.readLimit(bytes.capacity());
LongArrayValues indexValues = arrayForAddress(wire, secondaryAddress);
int index3 = (int) ((sequenceNumber >>> indexSpacingBits) & (indexCount - 1));

代码示例来源:origin: net.openhft/chronicle-queue

private void inACycleFound(Bytes<?> bytes) {
  context.closeReadLimit(bytes.capacity());
  wire().readAndSetLength(bytes.readPosition());
  long end = bytes.readLimit();
  context.closeReadPosition(end);
  Jvm.optionalSafepoint();
}

代码示例来源:origin: net.openhft/chronicle-map

bs.readLimit(bs.capacity());
bs.readPosition(keySizeOffset);
long keySize = keySizeMarshaller.readSize(bs);

代码示例来源:origin: net.openhft/chronicle-queue

private boolean inACycle(boolean includeMetaData)
    throws EOFException {
  Jvm.optionalSafepoint();
  if (readAfterReplicaAcknowledged && inACycleCheckRep()) return false;
  Jvm.optionalSafepoint();
  if (direction != TailerDirection.FORWARD && !inACycleNotForward()) return false;
  Jvm.optionalSafepoint();
  Wire wire = wire();
  Bytes<?> bytes = wire.bytes();
  bytes.readLimit(bytes.capacity());
  switch (wire.readDataHeader(includeMetaData)) {
    case NONE:
      Jvm.optionalSafepoint();
      // no more polling - appender will always write (or recover) EOF
      return false;
    case META_DATA:
      Jvm.optionalSafepoint();
      context.metaData(true);
      break;
    case DATA:
      Jvm.optionalSafepoint();
      context.metaData(false);
      break;
  }
  Jvm.optionalSafepoint();
  inACycleFound(bytes);
  Jvm.optionalSafepoint();
  return true;
}

代码示例来源:origin: net.openhft/chronicle-map

return -1;
if (e.keyEnd() > s.segmentBytes.capacity()) {
  report(corruptionListener, corruption, segmentIndex, () ->
      format("Wrong key size: {}", e.keySize)
  if (entryAndChecksumEnd > s.segmentBytes.capacity()) {
    report(corruptionListener, corruption, segmentIndex, () ->
        format("Wrong value size: {}, key: {}", e.valueSize, e.key())

代码示例来源:origin: net.openhft/chronicle-map

return -1;
if ((this.keyEnd()) > (this.segmentBytes().capacity())) {
  ChronicleHashCorruptionImpl.report(corruptionListener, corruption, segmentIndex, () -> ChronicleHashCorruptionImpl.format("Wrong key size: {}", this.keySize()));
  return -1;
  if (entryAndChecksumEnd > (this.segmentBytes().capacity())) {
    ChronicleHashCorruptionImpl.report(corruptionListener, corruption, segmentIndex, () -> ChronicleHashCorruptionImpl.format("Wrong value size: {}, key: {}", this.valueSize(), this.key()));
    return -1;

代码示例来源:origin: net.openhft/chronicle-map

return -1;
if ((this.keyEnd()) > (this.segmentBytes().capacity())) {
  ChronicleHashCorruptionImpl.report(corruptionListener, corruption, segmentIndex, () -> ChronicleHashCorruptionImpl.format("Wrong key size: {}", this.keySize()));
  return -1;
  if (entryAndChecksumEnd > (this.segmentBytes().capacity())) {
    ChronicleHashCorruptionImpl.report(corruptionListener, corruption, segmentIndex, () -> ChronicleHashCorruptionImpl.format("Wrong value size: {}, key: {}", this.valueSize(), this.key()));
    return -1;

相关文章

微信公众号

最新文章

更多