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

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

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

Bytes.readSkip介绍

暂无

代码示例

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

long linearScanByPosition0(@NotNull final Wire wire,
              final long toPosition,
              long indexOfNext,
  while (bytes.readPosition() <= toPosition) {
    WireIn.HeaderType headerType;
    try {
    if (!inclusive && toPosition == bytes.readPosition())
      return i;
        int header = bytes.readVolatileInt(bytes.readPosition());
        throw new IllegalArgumentException(
            "You can't know the index for an entry which hasn't been written. " +
    int len = Wires.lengthOf(header);
    assert Wires.isReady(header);
    bytes.readSkip(len);

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

@NotNull
private ScanResult linearScan0(@NotNull final Wire wire,
                final long toIndex,
                long fromKnownIndex,
                long knownAddress) {
  this.linearScanCount++;
  @NotNull final Bytes<?> bytes = wire.bytes();
          return ScanResult.NOT_REACHED;
        bytes.readSkip(Wires.lengthOf(header));
        continue;

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

long moveToEnd(final Wire wire) {
  Sequence sequence1 = this.sequence;
  if (sequence1 != null) {
    for (int i = 0; i < 128; i++) {
      long endAddress = writePosition.getVolatileValue();
      if (endAddress == 0)
        return -1;
      long sequence = sequence1.getSequence(endAddress);
      if (sequence == Sequence.NOT_FOUND_RETRY)
        continue;
      if (sequence == Sequence.NOT_FOUND)
        return -1;
      Bytes<?> bytes = wire.bytes();
      bytes.readPosition(endAddress);
      for (; ; ) {
        int header = bytes.readVolatileInt(endAddress);
        if (header == 0 || Wires.isNotComplete(header))
          return sequence;
        int len = Wires.lengthOf(header) + 4;
        bytes.readSkip(len);
        endAddress += len;
        if (Wires.isData(header))
          sequence += 1;
      }
    }
  }
  return -1;
}

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

public static void parse8bit_SB1(@org.jetbrains.annotations.NotNull @NotNull Bytes bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder sb, int utflen)
    throws BufferUnderflowException {
  if (utflen > bytes.readRemaining())
    throw new BufferUnderflowException();
  @Nullable NativeBytesStore nbs = (NativeBytesStore) bytes.bytesStore();
  long offset = bytes.readPosition();
  int count = BytesInternal.parse8bit_SB1(offset, nbs, sb, utflen);
  bytes.readSkip(count);
}

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

@org.jetbrains.annotations.NotNull
public static Bytes fromHexString(@org.jetbrains.annotations.NotNull String s) {
  try {
    Bytes in = Bytes.from(s);
    Bytes out = Bytes.elasticByteBuffer();
    OUTER:
    while (in.readRemaining() > 0) {
      in.parseHexLong();
      for (int i = 0; i < 16; i++) {
        if (in.peekUnsignedByte() == ' ') {
          in.readSkip(1);
          if (in.peekUnsignedByte() == ' ')
            break OUTER;
        }
        long value = in.parseHexLong();
        out.writeByte((byte) value);
      }
      if (in.readByte(in.readPosition() - 1) <= ' ')
        in.readSkip(-1);
      in.skipTo(StopCharTesters.CONTROL_STOP);
    }
    return out;
  } catch (BufferUnderflowException | BufferOverflowException e) {
    throw new AssertionError(e);
  }
}

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

long linearScanByPosition0(@NotNull final Wire wire,
              final long toPosition,
              long indexOfNext,
  while (bytes.readPosition() <= toPosition) {
    WireIn.HeaderType headerType;
    try {
    if (!inclusive && toPosition == bytes.readPosition())
      return i;
        int header = bytes.readVolatileInt(bytes.readPosition());
        throw new IllegalArgumentException(
            "You can't know the index for an entry which hasn't been written. " +
    int len = Wires.lengthOf(header);
    assert Wires.isReady(header);
    bytes.readSkip(len);

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

@NotNull
private ScanResult linearScan0(@NotNull final Wire wire,
                final long toIndex,
                long fromKnownIndex,
                long knownAddress) {
  this.linearScanCount++;
  @NotNull final Bytes<?> bytes = wire.bytes();
          return ScanResult.NOT_REACHED;
        bytes.readSkip(Wires.lengthOf(header));
        continue;

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

public void alignReadPosition(Bytes entry) {
  long positionAddr = entry.addressForRead(entry.readPosition());
  long skip = alignAddr(positionAddr, alignment) - positionAddr;
  if (skip > 0)
    entry.readSkip(skip);
}

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

/**
   * converts the bytes to a ISO-8859-1 String, the end of the string is either the bytes .limit
   * () or a byte containing the stopByte ( which ever comes first ). If the string can be
   * obtained from the pool, this string is used instead. otherwise, the string is added to the
   * pool.
   *
   * @param bytes  the bytes to convert to a string
   * @param length parse the string up to the length
   * @return the string made from bytes only ( rather than chars )
   */
  public String intern(@NotNull final Bytes bytes, int length) {
    try {
      int hash32 = BytesStoreHash.hash32(bytes, length);
      int h = hash32 & mask;
      String s = interner[h];
      long position = bytes.readPosition();
      if (BytesUtil.bytesEqual(s, bytes, position, length))
        return s;
      int h2 = (hash32 >> shift) & mask;
      String s2 = interner[h2];
      if (BytesUtil.bytesEqual(s2, bytes, position, length))
        return s2;

      char[] chars = toCharArray(bytes, position, length);
      return interner[s == null || (s2 != null && toggle()) ? h : h2] = StringUtils.newString(chars);
    } finally {
      bytes.readSkip(length);
    }
  }
}

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

long moveToEnd(final Wire wire) {
  Sequence sequence1 = this.sequence;
  if (sequence1 != null) {
    for (int i = 0; i < 128; i++) {
      long endAddress = writePosition.getVolatileValue();
      if (endAddress == 0)
        return -1;
      long sequence = sequence1.getSequence(endAddress);
      if (sequence == Sequence.NOT_FOUND_RETRY)
        continue;
      if (sequence == Sequence.NOT_FOUND)
        return -1;
      Bytes<?> bytes = wire.bytes();
      bytes.readPosition(endAddress);
      for (; ; ) {
        int header = bytes.readVolatileInt(endAddress);
        if (header == 0 || Wires.isNotComplete(header))
          return sequence;
        int len = Wires.lengthOf(header) + 4;
        bytes.readSkip(len);
        endAddress += len;
        if (Wires.isData(header))
          sequence += 1;
      }
    }
  }
  return -1;
}

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

private static void readUtf8_SB1(
    @org.jetbrains.annotations.NotNull @NotNull Bytes bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder appendable, @org.jetbrains.annotations.NotNull @NotNull StopCharTester tester)
    throws IOException, BufferUnderflowException {
  @org.jetbrains.annotations.Nullable NativeBytesStore nb = (NativeBytesStore) bytes.bytesStore();
  int i = 0, len = Maths.toInt32(bytes.readRemaining());
  long address = nb.address + nb.translate(bytes.readPosition());
  @org.jetbrains.annotations.Nullable Memory memory = nb.memory;
        break;
      if (tester.isStopChar(c)) {
        bytes.readSkip(i + 1);
        StringUtils.setCount(appendable, i);
        return;
        break;
      if (tester.isStopChar(c)) {
        bytes.readSkip(i + 1);
        StringUtils.setCount(appendable, i);
        return;
  bytes.readSkip(i);
  if (i < len) {
    readUtf8_SB2(bytes, appendable, tester);

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

public void processReplicatedEvent(byte remoteNodeIdentifier, Bytes replicatedInputBytes) {
  long timestamp = replicatedInputBytes.readStopBit();
  byte identifier = replicatedInputBytes.readByte();
  this.initReplicationUpdate(identifier, timestamp, remoteNodeIdentifier);
  boolean isDeleted = replicatedInputBytes.readBoolean();
  long keySize = this.m().keySizeMarshaller.readSize(replicatedInputBytes);
  long keyOffset = replicatedInputBytes.readPosition();
  this.initInputKey(this.getInputKeyBytesAsData(replicatedInputBytes, keyOffset, keySize));
  replicatedInputBytes.readSkip(keySize);
  if (isDeleted) {
    this.innerUpdateLock.lock();
    this.m().remoteOperations.remove(this);
  } else {
    long valueSize = this.m().valueSizeMarshaller.readSize(replicatedInputBytes);
    long valueOffset = replicatedInputBytes.readPosition();
    Data<V> value = this.wrapValueBytesAsData(replicatedInputBytes, valueOffset, valueSize);
    replicatedInputBytes.readSkip(valueSize);
    this.innerWriteLock.lock();
    this.m().remoteOperations.put(this, value);
  }
}

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

@org.jetbrains.annotations.NotNull
@NotNull
default S writeSome(@org.jetbrains.annotations.NotNull @NotNull Bytes bytes) {
  try {
    long length = Math.min(bytes.readRemaining(), writeRemaining());
    if (length + writePosition() >= 1 << 20)
      length = Math.min(bytes.readRemaining(), realCapacity() - writePosition());
    write(bytes, bytes.readPosition(), length);
    if (length == bytes.readRemaining()) {
      bytes.clear();
    } else {
      bytes.readSkip(length);
      if (bytes.writePosition() > bytes.realCapacity() / 2)
        bytes.compact();
    }
    return (S) this;
  } catch (BufferOverflowException | BufferUnderflowException | IllegalArgumentException e) {
    throw new AssertionError(e);
  }
}

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

public void processReplicatedEvent(byte remoteNodeIdentifier, Bytes replicatedInputBytes) {
  long timestamp = replicatedInputBytes.readStopBit();
  byte identifier = replicatedInputBytes.readByte();
  ru.initReplicationUpdate(identifier, timestamp, remoteNodeIdentifier);
  boolean isDeleted = replicatedInputBytes.readBoolean();
  long keySize = mh.m().keySizeMarshaller.readSize(replicatedInputBytes);
  long keyOffset = replicatedInputBytes.readPosition();
  q.initInputKey(q.getInputKeyBytesAsData(replicatedInputBytes, keyOffset, keySize));
  replicatedInputBytes.readSkip(keySize);
  if (isDeleted) {
    s.innerUpdateLock.lock();
    mh.m().remoteOperations.remove(this);
  } else {
    long valueSize = mh.m().valueSizeMarshaller.readSize(replicatedInputBytes);
    long valueOffset = replicatedInputBytes.readPosition();
    Data<V> value = q.wrapValueBytesAsData(replicatedInputBytes, valueOffset, valueSize);
    replicatedInputBytes.readSkip(valueSize);
    s.innerWriteLock.lock();
    mh.m().remoteOperations.put(this, value);
  }
}

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

public static void parseUtf8_SB1(@org.jetbrains.annotations.NotNull @NotNull Bytes bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder sb, int utflen)
    throws UTFDataFormatRuntimeException, BufferUnderflowException {
  try {
    int count = 0;
    if (utflen > bytes.readRemaining()) {
      @org.jetbrains.annotations.NotNull final BufferUnderflowException bue = new BufferUnderflowException();
      bue.initCause(new IllegalStateException("utflen: " + utflen + ", readRemaining: " + bytes.readRemaining()));
      throw bue;
    long readPosition = bytes.readPosition();
    sb.ensureCapacity(utflen);
    bytes.readSkip(count);
    setCount(sb, count);
    if (count < utflen) {
      long rp0 = bytes.readPosition();
      try {
        parseUtf82(bytes, sb, utflen, count);

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

@Override
@NotNull
public NativeBytes writeSome(@NotNull Bytes bytes) {
  try {
    long length = Math.min(bytes.readRemaining(), writeRemaining());
    if (length + writePosition() >= 1 << 20)
      length = Math.min(bytes.readRemaining(), realCapacity() - writePosition());
    long offset = bytes.readPosition();
    long position = writePosition();
    ensureCapacity(position + length);
    optimisedWrite(bytes, offset, length);
    if (length == bytes.readRemaining()) {
      bytes.clear();
    } else {
      bytes.readSkip(length);
      if (bytes.writePosition() > bytes.realCapacity() / 2)
        bytes.compact();
    }
    return this;
  } catch (IllegalArgumentException | BufferUnderflowException | BufferOverflowException e) {
    throw new AssertionError(e);
  }
}

相关文章

微信公众号

最新文章

更多