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

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

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

Bytes.writeLong介绍

暂无

代码示例

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

private static void writeMessage(Wire wire, int messageSize) {
    Bytes<?> bytes = wire.bytes();
    long wp = bytes.writePosition();
    // TODO Optimise wire to give similar performance.
    if (false) {
      for (int i = 0; i < messageSize; i += 8)
        bytes.writeLong(0L);

    } else {
      long addr = bytes.addressForWrite(wp);
      Memory memory = OS.memory();
      for (int i = 0; i < messageSize; i += 16) {
        memory.writeLong(addr + i, 0L);
        memory.writeLong(addr + i + 8, 0L);
      }

      bytes.writeSkip(messageSize);
    }
    bytes.writeLong(wp, System.nanoTime());
  }
}

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

static void writeMany(Bytes bytes, int size) {
  for (int i = 0; i < size; i += 32) {
    bytes.writeInt(i);// 4 bytes
    bytes.writeFloat(i);// 4 bytes
    bytes.writeLong(i);// 8 bytes
    bytes.writeDouble(i);// 8 bytes
    bytes.writeUtf8("Hello!!"); // 8 bytes
  }
}

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

@Override
public void write(Bytes out, @NotNull Long toWrite) {
  out.writeLong(toWrite);
}

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

@Override
public void write(@NotNull Bytes out, long size, @NotNull Long toWrite) {
  out.writeLong(toWrite);
}

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

public static void lazyWrite(@NotNull Bytes bytes, long capacity) throws BufferOverflowException {
  assert (bytes.writePosition() & 0x7) == 0;
  bytes.writeLong(capacity);
  bytes.writeLong(0L); // used
  bytes.writeSkip(capacity << 3);
}

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

public static void write(@NotNull Bytes bytes, long capacity) throws BufferOverflowException, IllegalArgumentException {
  assert (bytes.writePosition() & 0x7) == 0;
  bytes.writeLong(capacity);
  bytes.writeLong(0L); // used
  long start = bytes.writePosition();
  bytes.zeroOut(start, start + (capacity << 3));
  bytes.writeSkip(capacity << 3);
}

代码示例来源:origin: peter-lawrey/Performance-Examples

@Benchmark
  public long usingBytes() throws IOException, ClassNotFoundException {
    bytes.clear();
    bytes.writeLong(System.currentTimeMillis());
    return bytes.readLong();
  }
}

代码示例来源:origin: peter-lawrey/Performance-Examples

public ChronicleBytesCASPingPongMain() throws IOException {
  bytes = MappedBytes.mappedBytes("deleteme", OS.pageSize());
  bytes.writeLong(COUNTER_OFFSET, 0L);
  bytes.writeInt(TOGGLE_OFFSET, 0);
}

代码示例来源:origin: com.wavefront/proxy

@Override
public void write(Bytes out, long size, @NotNull AgentDigest toWrite) {
 // Merge in all buffered values
 int numCentroids = toWrite.centroidCount();
 // Just for sanity, comment out for production use
 Preconditions.checkArgument(size == toWrite.encodedSize());
 // Write compression
 out.writeShort(toWrite.compression);
 // Time
 out.writeLong(toWrite.dispatchTimeMillis);
 // Centroids
 for (int i = 0; i < numCentroids; ++i) {
  out.writeFloat((float) toWrite.weight[i]);
  out.writeFloat((float) toWrite.mean[i]);
 }
}

代码示例来源:origin: wavefrontHQ/java

@Override
public void write(Bytes out, long size, @NotNull AgentDigest toWrite) {
 // Merge in all buffered values
 int numCentroids = toWrite.centroidCount();
 // Just for sanity, comment out for production use
 Preconditions.checkArgument(size == toWrite.encodedSize());
 // Write compression
 out.writeShort(toWrite.compression);
 // Time
 out.writeLong(toWrite.dispatchTimeMillis);
 // Centroids
 for (int i = 0; i < numCentroids; ++i) {
  out.writeFloat((float) toWrite.weight[i]);
  out.writeFloat((float) toWrite.mean[i]);
 }
}

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

void updateReplicationState(byte identifier, long timestamp) {
  initDelayedUpdateChecksum(true);
  Bytes segmentBytes = s.segmentBytesForWrite();
  segmentBytes.writePosition(replicationBytesOffset);
  segmentBytes.writeLong(timestamp);
  segmentBytes.writeByte(identifier);
}

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

private static void writeMessage(Wire wire, int messageSize) {
    Bytes<?> bytes = wire.bytes();
    long wp = bytes.writePosition();
    long addr = bytes.addressForWrite(wp);
    Memory memory = OS.memory();
    for (int i = 0; i < messageSize; i += 16) {
      memory.writeLong(addr + i, 0L);
      memory.writeLong(addr + i + 8, 0L);
    }

    bytes.writeSkip(messageSize);
    bytes.writeLong(wp, System.nanoTime());
  }
}

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

void updateReplicationState(byte identifier, long timestamp) {
  initDelayedUpdateChecksum(true);
  Bytes segmentBytes = this.segmentBytesForWriteGuarded();
  segmentBytes.writePosition(replicationBytesOffset());
  segmentBytes.writeLong(timestamp);
  segmentBytes.writeByte(identifier);
}

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

void updateReplicationState(byte identifier, long timestamp) {
  initDelayedUpdateChecksum(true);
  Bytes segmentBytes = this.segmentBytesForWriteGuarded();
  segmentBytes.writePosition(replicationBytesOffset());
  segmentBytes.writeLong(timestamp);
  segmentBytes.writeByte(identifier);
}

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

default void readWithLength(Bytes bytes) {
  bytes.clear();
  int length = Maths.toUInt31(readStopBit());
  int i;
  for (i = 0; i < length - 7; i++)
    bytes.writeLong(readLong());
  for (; i < length; i++)
    bytes.writeByte(readByte());
}

相关文章

微信公众号

最新文章

更多