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

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

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

Bytes.readLong介绍

暂无

代码示例

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

static void readMany(Bytes bytes, int size) {
  for (int i = 0; i < size; i += 32) {
    s32 = bytes.readInt();// 4 bytes
    f32 = bytes.readFloat();// 4 bytes
    s64 = bytes.readLong();// 8 bytes
    f64 = bytes.readDouble();// 8 bytes
    s = bytes.readUtf8(); // 8 bytes
    assertEquals("Hello!!", s);
  }
}

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

private static long readMessage(Bytes<?> bytes) {
  Jvm.safepoint();
  long start = bytes.readLong();
  if (true) {
    long rp = bytes.readPosition();
    long rl = bytes.readLimit();
    long addr = bytes.addressForRead(rp);
    long addrEnd = bytes.addressForRead(rl);
    Memory memory = OS.memory();
    for (addr += 8; addr + 7 < addrEnd; addr += 8)
      memory.readLong(addr);
  } else {
    while (bytes.readRemaining() > 7)
      bytes.readLong();
  }
  Jvm.safepoint();
  return start;
}

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

@NotNull
@Override
public Long read(Bytes in, @Nullable Long using) {
  return in.readLong();
}

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

@NotNull
@Override
public Long read(@NotNull Bytes in, long size, @Nullable Long using) {
  return in.readLong();
}

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

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

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

@NotNull
@Override
public AgentDigest read(Bytes in, long size, @Nullable AgentDigest using) {
 Preconditions.checkArgument(size >= FIXED_SIZE);
 short compression = in.readShort();
 if (using == null || using.compression != compression) {
  using = new AgentDigest(compression, in.readLong());
 } else {
  using.dispatchTimeMillis = in.readLong();
 }
 using.totalWeight = 0d;
 using.lastUsedCell = (int) ((size - FIXED_SIZE) / PER_CENTROID_SIZE);
 using.tempUsed = 0;
 using.unmergedWeight = 0D;
 // need explicit nulling of weight past lastUsedCell
 Arrays.fill(using.weight, using.lastUsedCell, using.weight.length, 0D);
 for (int i = 0; i < using.lastUsedCell; ++i) {
  float weight = in.readFloat();
  using.weight[i] = weight;
  using.mean[i] = in.readFloat();
  using.totalWeight += weight;
 }
 return using;
}

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

@NotNull
@Override
public AgentDigest read(Bytes in, long size, @Nullable AgentDigest using) {
 Preconditions.checkArgument(size >= FIXED_SIZE);
 short compression = in.readShort();
 if (using == null || using.compression != compression) {
  using = new AgentDigest(compression, in.readLong());
 } else {
  using.dispatchTimeMillis = in.readLong();
 }
 using.totalWeight = 0d;
 using.lastUsedCell = (int) ((size - FIXED_SIZE) / PER_CENTROID_SIZE);
 using.tempUsed = 0;
 using.unmergedWeight = 0D;
 // need explicit nulling of weight past lastUsedCell
 Arrays.fill(using.weight, using.lastUsedCell, using.weight.length, 0D);
 for (int i = 0; i < using.lastUsedCell; ++i) {
  float weight = in.readFloat();
  using.weight[i] = weight;
  using.mean[i] = in.readFloat();
  using.totalWeight += weight;
 }
 return using;
}

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

/**
 * This method does not set a segment lock, A segment lock should be obtained before calling
 * this method, especially when being used in a multi threaded context.
 */
@Override
public void readExternalEntry(@NotNull Bytes source, byte remoteNodeIdentifier) {
  byte hunk = source.readByte();
  if (hunk == BOOTSTRAP_TIME_HUNK) {
    setRemoteNodeCouldBootstrapFrom(remoteNodeIdentifier, source.readLong());
  } else {
    assert hunk == ENTRY_HUNK;
    try (CompiledReplicatedMapQueryContext<K, V, R> remoteOpContext = mapContext()) {
      remoteOpContext.processReplicatedEvent(remoteNodeIdentifier, source);
    }
  }
}

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

public boolean equalsBytes(@NotNull Bytes b2, long remaining) {
  long i = 0;
  try {
    for (; i < remaining - 7; i += 8)
      if (readLong(readPosition() + i) != b2.readLong(b2.readPosition() + i))
        return false;
    for (; i < remaining; i++)
      if (readByte(readPosition() + i) != b2.readByte(b2.readPosition() + i))
        return false;
  } catch (BufferUnderflowException e) {
    throw Jvm.rethrow(e);
  }
  return true;
}

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

private static long readMessage(Bytes<?> bytes) {
  Jvm.safepoint();
  long start = bytes.readLong();
  long rp = bytes.readPosition();
  long rl = bytes.readLimit();
  long addr = bytes.addressForRead(rp);
  long addrEnd = bytes.addressForRead(rl);
  Memory memory = OS.memory();
  for (addr += 8; addr + 7 < addrEnd; addr += 8)
    memory.readLong(addr);
  Jvm.safepoint();
  return start;
}

相关文章

微信公众号

最新文章

更多