Java Code Examples for net.openhft.chronicle.bytes.Bytes#writeDouble()

The following examples show how to use net.openhft.chronicle.bytes.Bytes#writeDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Issue43Test.java    From Chronicle-Map with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Bytes bytes, @NotNull ValueWrapper vw) {
    bytes.writeInt(vw.values.length);

    for (int i = 0; i < vw.values.length; i++) {
        bytes.writeDouble(vw.values[i]);
    }
}
 
Example 2
Source File: RawAccessJava.java    From Chronicle-Queue with Apache License 2.0 5 votes vote down vote up
@Test
public void Appender() {
    if (!assert_from_cpp())
        return;

    String tmp = "/dev/shm/RawAccessJtoC";
    System.out.println(tmp); // so C++ knows this ran rather than skipped

    try (ChronicleQueue cq = SingleChronicleQueueBuilder.binary(tmp).build()) {

        ExcerptAppender appender = cq.acquireAppender();

        for (int i = 0; i < COUNT; ++i) {
            try (DocumentContext dc = appender.writingDocument()) {

                Bytes bytes = dc.wire().bytes();

                // will contain the size of the blob
                long start = bytes.writePosition();
                bytes.writeSkip(RAW_SIZE_PREFIX);

                {
                    bytes.writeByte((byte) 0xab);
                    bytes.writeShort((short) 12);
                    bytes.writeInt(123);
                    bytes.writeLong(123456789L);
                    bytes.writeFloat(1.234f);
                    bytes.writeDouble(123.456);
                    bytes.writeChar('a');
                    bytes.write8bit("Hello World");
                }

                long end = bytes.writePosition();
                bytes.writeInt(start, (int) (end - start - RAW_SIZE_PREFIX));
            }
        }
    }
}
 
Example 3
Source File: DoubleMarshaller.java    From Chronicle-Map with Apache License 2.0 4 votes vote down vote up
@Override
public void write(@NotNull Bytes out, long size, @NotNull Double toWrite) {
    out.writeDouble(toWrite);
}
 
Example 4
Source File: DoubleMarshaller.java    From Chronicle-Map with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Bytes out, @NotNull Double toWrite) {
    out.writeDouble(toWrite);
}