Search in sources :

Example 21 with DataOutputBuffer

use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.

the class RangeSliceReply method getReply.

public Message getReply(Message originalMessage) throws IOException {
    int size = DBConstants.intSize;
    for (Row row : rows) size += Row.serializer().serializedSize(row, originalMessage.getVersion());
    DataOutputBuffer buffer = new DataOutputBuffer(size);
    buffer.writeInt(rows.size());
    for (Row row : rows) Row.serializer().serialize(row, buffer, originalMessage.getVersion());
    assert buffer.getLength() == buffer.getData().length;
    return originalMessage.getReply(FBUtilities.getBroadcastAddress(), buffer.getData(), originalMessage.getVersion());
}
Also used : DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 22 with DataOutputBuffer

use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.

the class Column method updateDigest.

@Override
public void updateDigest(MessageDigest digest) {
    digest.update(name.duplicate());
    digest.update(value.duplicate());
    DataOutputBuffer buffer = new DataOutputBuffer();
    try {
        buffer.writeLong(timestamp);
        buffer.writeByte(serializationFlags());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    digest.update(buffer.getData(), 0, buffer.getLength());
}
Also used : DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) IOException(java.io.IOException)

Example 23 with DataOutputBuffer

use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.

the class PrecompactedRow method write.

@Override
public long write(DataOutput out) throws IOException {
    assert compactedCf != null;
    DataOutputBuffer buffer = new DataOutputBuffer();
    DataOutputBuffer headerBuffer = new DataOutputBuffer();
    ColumnIndexer.serialize(compactedCf, headerBuffer);
    ColumnFamily.serializer().serializeForSSTable(compactedCf, buffer);
    int dataSize = headerBuffer.getLength() + buffer.getLength();
    out.writeLong(dataSize);
    out.write(headerBuffer.getData(), 0, headerBuffer.getLength());
    out.write(buffer.getData(), 0, buffer.getLength());
    return dataSize;
}
Also used : DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 24 with DataOutputBuffer

use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.

the class AbstractTransactionMessage method getMessage.

@Override
public Message getMessage(Integer version) throws IOException {
    DataOutputBuffer dob = new DataOutputBuffer();
    serializer().serialize(this, dob, version);
    logger.debug("getMessage called on " + this + " serialized into " + dob.getLength());
    return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.TRANSACTION_MESSAGE, Arrays.copyOf(dob.getData(), dob.getLength()), version);
}
Also used : Message(org.apache.cassandra.net.Message) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 25 with DataOutputBuffer

use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.

the class Migration method serialize.

public ByteBuffer serialize() throws IOException {
    // super deflate
    org.apache.cassandra.db.migration.avro.Migration mi = new org.apache.cassandra.db.migration.avro.Migration();
    mi.old_version = new org.apache.cassandra.utils.avro.UUID();
    mi.old_version.bytes(UUIDGen.decompose(lastVersion));
    mi.new_version = new org.apache.cassandra.utils.avro.UUID();
    mi.new_version.bytes(UUIDGen.decompose(newVersion));
    mi.classname = new org.apache.avro.util.Utf8(this.getClass().getName());
    // TODO: Avro RowMutation serialization?
    DataOutputBuffer dob = new DataOutputBuffer();
    try {
        RowMutation.serializer().serialize(rm, dob, MessagingService.version_);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    mi.row_mutation = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
    // sub deflate
    this.subdeflate(mi);
    // serialize
    return SerDeUtils.serializeWithSchema(mi);
}
Also used : IOException(java.io.IOException) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) org.apache.cassandra.db(org.apache.cassandra.db)

Aggregations

DataOutputBuffer (org.apache.cassandra.io.util.DataOutputBuffer)68 Test (org.junit.Test)25 DataInputBuffer (org.apache.cassandra.io.util.DataInputBuffer)17 IOException (java.io.IOException)16 ByteBuffer (java.nio.ByteBuffer)15 ByteArrayInputStream (java.io.ByteArrayInputStream)10 DataInputStream (java.io.DataInputStream)10 DataInputPlus (org.apache.cassandra.io.util.DataInputPlus)8 File (java.io.File)6 CRC32 (java.util.zip.CRC32)5 InetAddress (java.net.InetAddress)3 ArrayList (java.util.ArrayList)3 DataOutputBufferFixed (org.apache.cassandra.io.util.DataOutputBufferFixed)3 SequentialWriter (org.apache.cassandra.io.util.SequentialWriter)3 Message (org.apache.cassandra.net.Message)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataOutputStream (java.io.DataOutputStream)2 Map (java.util.Map)2 UUID (java.util.UUID)2 Mutation (org.apache.cassandra.db.Mutation)2