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); } }
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; }
@NotNull @Override public Long read(Bytes in, @Nullable Long using) { return in.readLong(); }
@NotNull @Override public Long read(@NotNull Bytes in, long size, @Nullable Long using) { return in.readLong(); }
@Benchmark public long usingBytes() throws IOException, ClassNotFoundException { bytes.clear(); bytes.writeLong(System.currentTimeMillis()); return bytes.readLong(); } }
@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; }
@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; }
/** * 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); } } }
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; }
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; }