Search in sources :

Example 16 with ObjectDataOutput

use of com.hazelcast.nio.ObjectDataOutput in project hazelcast by hazelcast.

the class DataSerializableImplementsVersionedTest method isGetVersionCalledOnWrite.

private boolean isGetVersionCalledOnWrite(DataSerializable dataSerializable) throws IOException {
    ObjectDataOutput out = getObjectDataOutput();
    when(out.getVersion()).thenReturn(Versions.V4_0);
    try {
        dataSerializable.writeData(out);
    } catch (NullPointerException | UnsupportedOperationException ignored) {
    }
    return isGetVersionCalled(out);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput)

Example 17 with ObjectDataOutput

use of com.hazelcast.nio.ObjectDataOutput in project hazelcast by hazelcast.

the class SerializationV1Portable method writePortable.

@Override
public void writePortable(PortableWriter out) throws IOException {
    out.writeByte("1", aByte);
    out.writeBoolean("2", aBoolean);
    out.writeChar("3", character);
    out.writeShort("4", aShort);
    out.writeInt("5", integer);
    out.writeLong("6", aLong);
    out.writeFloat("7", aFloat);
    out.writeDouble("8", aDouble);
    out.writeString("9", string);
    out.writeByteArray("a1", bytes);
    out.writeBooleanArray("a2", booleans);
    out.writeCharArray("a3", chars);
    out.writeShortArray("a4", shorts);
    out.writeIntArray("a5", ints);
    out.writeLongArray("a6", longs);
    out.writeFloatArray("a7", floats);
    out.writeDoubleArray("a8", doubles);
    out.writeStringArray("a9", strings);
    if (innerPortable == null) {
        out.writeNullPortable("p", INNER_PORTABLE.getFactoryId(), INNER_PORTABLE.getClassId());
    } else {
        out.writePortable("p", innerPortable);
    }
    ObjectDataOutput rawDataOutput = out.getRawDataOutput();
    boolean isNotNull = dataSerializable != null;
    if (isNotNull) {
        rawDataOutput.writeBoolean(isNotNull);
        dataSerializable.writeData(rawDataOutput);
    } else {
        rawDataOutput.writeBoolean(isNotNull);
    }
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput)

Example 18 with ObjectDataOutput

use of com.hazelcast.nio.ObjectDataOutput in project hazelcast by hazelcast.

the class ObjectCarryingPortable method writePortable.

@Override
public void writePortable(PortableWriter writer) throws IOException {
    ObjectDataOutput output = writer.getRawDataOutput();
    output.writeObject(object);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput)

Example 19 with ObjectDataOutput

use of com.hazelcast.nio.ObjectDataOutput in project hazelcast by hazelcast.

the class RawDataPortable method writePortable.

@Override
public void writePortable(PortableWriter writer) throws IOException {
    writer.writeLong("l", l);
    writer.writeCharArray("c", c);
    writer.writePortable("p", p);
    final ObjectDataOutput output = writer.getRawDataOutput();
    output.writeInt(k);
    output.writeString(s);
    output.writeObject(sds);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput)

Example 20 with ObjectDataOutput

use of com.hazelcast.nio.ObjectDataOutput in project hazelcast by hazelcast.

the class APortable method writePortable.

public void writePortable(PortableWriter writer) throws IOException {
    writer.writeBoolean("bool", bool);
    writer.writeByte("b", b);
    writer.writeChar("c", c);
    writer.writeDouble("d", d);
    writer.writeShort("s", s);
    writer.writeFloat("f", f);
    writer.writeInt("i", i);
    writer.writeLong("l", l);
    writer.writeString("str", str);
    if (p != null) {
        writer.writePortable("p", p);
    } else {
        writer.writeNullPortable("p", ReferenceObjects.PORTABLE_FACTORY_ID, ReferenceObjects.PORTABLE_CLASS_ID);
    }
    writer.writeBooleanArray("booleans", booleans);
    writer.writeByteArray("bs", bytes);
    writer.writeCharArray("cs", chars);
    writer.writeDoubleArray("ds", doubles);
    writer.writeShortArray("ss", shorts);
    writer.writeFloatArray("fs", floats);
    writer.writeIntArray("is", ints);
    writer.writeLongArray("ls", longs);
    writer.writeStringArray("strs", strings);
    writer.writePortableArray("ps", portables);
    writer.writeBooleanArray("booleansNull", booleansNull);
    writer.writeByteArray("bsNull", bytesNull);
    writer.writeCharArray("csNull", charsNull);
    writer.writeDoubleArray("dsNull", doublesNull);
    writer.writeShortArray("ssNull", shortsNull);
    writer.writeFloatArray("fsNull", floatsNull);
    writer.writeIntArray("isNull", intsNull);
    writer.writeLongArray("lsNull", longsNull);
    writer.writeStringArray("strsNull", stringsNull);
    ObjectDataOutput dataOutput = writer.getRawDataOutput();
    dataOutput.writeBoolean(bool);
    dataOutput.writeByte(b);
    dataOutput.writeChar(c);
    dataOutput.writeDouble(d);
    dataOutput.writeShort(s);
    dataOutput.writeFloat(f);
    dataOutput.writeInt(i);
    dataOutput.writeLong(l);
    dataOutput.writeString(str);
    dataOutput.writeBooleanArray(booleans);
    dataOutput.writeByteArray(bytes);
    dataOutput.writeCharArray(chars);
    dataOutput.writeDoubleArray(doubles);
    dataOutput.writeShortArray(shorts);
    dataOutput.writeFloatArray(floats);
    dataOutput.writeIntArray(ints);
    dataOutput.writeLongArray(longs);
    dataOutput.writeUTFArray(strings);
    dataOutput.writeBooleanArray(booleansNull);
    dataOutput.writeByteArray(bytesNull);
    dataOutput.writeCharArray(charsNull);
    dataOutput.writeDoubleArray(doublesNull);
    dataOutput.writeShortArray(shortsNull);
    dataOutput.writeFloatArray(floatsNull);
    dataOutput.writeIntArray(intsNull);
    dataOutput.writeLongArray(longsNull);
    dataOutput.writeUTFArray(stringsNull);
    byteSize = (byte) bytes.length;
    dataOutput.write(byteSize);
    dataOutput.write(bytes);
    dataOutput.write(bytes, 1, 2);
    dataOutput.writeInt(str.length());
    dataOutput.writeChars(str);
    dataOutput.writeBytes(str);
    dataOutput.writeByte(unsignedByte);
    dataOutput.writeShort(unsignedShort);
    dataOutput.writeObject(portableObject);
    dataOutput.writeObject(identifiedDataSerializableObject);
    dataOutput.writeObject(customByteArraySerializableObject);
    dataOutput.writeObject(customStreamSerializableObject);
    writeData(dataOutput, data);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput)

Aggregations

ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)43 Test (org.junit.Test)15 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)7 SerializationConfig (com.hazelcast.config.SerializationConfig)6 StreamSerializer (com.hazelcast.nio.serialization.StreamSerializer)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Data (com.hazelcast.internal.serialization.Data)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)3 HeapData (com.hazelcast.internal.serialization.impl.HeapData)3 Data (com.hazelcast.nio.serialization.Data)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 SerializerConfig (com.hazelcast.config.SerializerConfig)2 DataWriter (com.hazelcast.internal.nio.DataWriter)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)2 DataSerializable (com.hazelcast.nio.serialization.DataSerializable)2