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

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

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

Bytes.appendUtf8介绍

暂无

代码示例

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

private static <T> BiFunction<T, Bytes, Bytes> toBytes(Class type) {
  if (type == String.class)
    return (t, bytes) -> (Bytes) bytes.appendUtf8((String) t);
  throw new UnsupportedOperationException("todo");
}

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

static <T> BiFunction<T, Bytes, Bytes> toBytes(@NotNull Class type, @NotNull Function<Bytes, Wire> wireType) {
  if (type == String.class)
    return (t, bytes) -> (Bytes) bytes.appendUtf8((String) t);
  if (Marshallable.class.isAssignableFrom(type))
    return (t, bytes) -> {
      t = acquireInstance(type, t);
      ((Marshallable) t).writeMarshallable(wireType.apply(bytes));
      return bytes;
    };
  throw new UnsupportedOperationException("todo");
}

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

@Nullable
@Override
public String getAndPut(String key, @NotNull String value) {
  Buffers b = BUFFERS.get();
  Bytes<ByteBuffer> bytes = b.valueBuffer;
  bytes.clear();
  bytes.appendUtf8(value);
  @Nullable BytesStore retBytes = kvStore.getAndPut(key, bytes);
  if (retBytes == null) return null;
  else {
    String s = retBytes.toString();
    retBytes.release();
    return s;
  }
}

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

public static <ACS extends Appendable & CharSequence> void append(ACS a, CharSequence cs, long start, long len) {
  if (a instanceof StringBuilder) {
    if (cs instanceof Bytes)
      ((StringBuilder) a).append(Bytes.toString(((Bytes) cs), start, len));
    else
      ((StringBuilder) a).append(cs.subSequence(Maths.toInt32(start), Maths.toInt32(len)));
  } else if (a instanceof Bytes) {
    ((Bytes) a).appendUtf8(cs, Maths.toInt32(start), Maths.toInt32(len));
  } else {
    throw new UnsupportedOperationException();
  }
}

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

public static void write(@NotNull Bytes bytes, long capacity) {
  long start = bytes.writePosition();
  bytes.write(SECTION1);
  bytes.append(capacity);
  while (bytes.writePosition() - start < CAPACITY + DIGITS) {
    bytes.writeUnsignedByte(' ');
  }
  bytes.write(SECTION2);
  bytes.write(ZERO);
  bytes.write(SECTION3);
  for (long i = 0; i < capacity; i++) {
    if (i > 0)
      bytes.appendUtf8(", ");
    bytes.write(ZERO);
  }
  bytes.write(SECTION4);
}

相关文章

微信公众号

最新文章

更多