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());
}
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());
}
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;
}
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);
}
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);
}
Aggregations