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()); } }
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 } }
@Override public void write(Bytes out, @NotNull Long toWrite) { out.writeLong(toWrite); }
@Override public void write(@NotNull Bytes out, long size, @NotNull Long toWrite) { out.writeLong(toWrite); }
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); }
@Benchmark public long usingBytes() throws IOException, ClassNotFoundException { bytes.clear(); bytes.writeLong(System.currentTimeMillis()); return bytes.readLong(); } }
public ChronicleBytesCASPingPongMain() throws IOException { bytes = MappedBytes.mappedBytes("deleteme", OS.pageSize()); bytes.writeLong(COUNTER_OFFSET, 0L); bytes.writeInt(TOGGLE_OFFSET, 0); }
@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]); } }
@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]); } }
void updateReplicationState(byte identifier, long timestamp) { initDelayedUpdateChecksum(true); Bytes segmentBytes = s.segmentBytesForWrite(); segmentBytes.writePosition(replicationBytesOffset); segmentBytes.writeLong(timestamp); segmentBytes.writeByte(identifier); }
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()); } }
void updateReplicationState(byte identifier, long timestamp) { initDelayedUpdateChecksum(true); Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(replicationBytesOffset()); segmentBytes.writeLong(timestamp); segmentBytes.writeByte(identifier); }
void updateReplicationState(byte identifier, long timestamp) { initDelayedUpdateChecksum(true); Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(replicationBytesOffset()); segmentBytes.writeLong(timestamp); segmentBytes.writeByte(identifier); }
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()); }