~posulliv/drizzle/memcached_applier

« back to all changes in this revision

Viewing changes to drizzled/message/binary_log.cc

  • Committer: Jay Pipes
  • Date: 2009-08-03 14:23:22 UTC
  • mfrom: (1039.2.68 staging)
  • mto: This revision was merged to the branch mainline in revision 1078.
  • Revision ID: jpipes@serialcoder-20090803142322-1g67h7su9mocg9ig
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
#include <google/protobuf/io/coded_stream.h>
5
5
 
6
 
using namespace google::protobuf;
7
 
using namespace google::protobuf::io;
 
6
using namespace google;
8
7
 
9
8
bool
10
 
BinaryLog::Event::write(CodedOutputStream* out) const
 
9
BinaryLog::Event::write(protobuf::io::CodedOutputStream* out) const
11
10
{
12
11
  // We frame each event in a length encoded in a special manner, and
13
12
  // end it with a CRC-32 checksum.
38
37
 
39
38
 
40
39
bool
41
 
BinaryLog::Event::read(CodedInputStream *in)
 
40
BinaryLog::Event::read(protobuf::io::CodedInputStream *in)
42
41
{
43
42
  unsigned char buf[LENGTH_ENCODE_MAX_BYTES + 1];
44
43
 
59
58
 
60
59
  // Create the right event based on the type code (is there something
61
60
  // better in the protobuf library?)
62
 
  Message *message= NULL;
 
61
  protobuf::Message *message= NULL;
63
62
  switch (m_type) {
64
63
  case QUERY:
65
64
    message= new BinaryLog::Query;
92
91
  // Read the event body as length bytes. It is necessary to limit the
93
92
  // stream since otherwise ParseFromCodedStream reads all bytes of
94
93
  // the stream.
95
 
  CodedInputStream::Limit limit= in->PushLimit(length);
 
94
  protobuf::io::CodedInputStream::Limit limit= in->PushLimit(length);
96
95
  if (!message->ParseFromCodedStream(in))
97
96
    return false;
98
97
  in->PopLimit(limit);
116
115
void
117
116
BinaryLog::Event::print(std::ostream& out) const
118
117
{
119
 
  using namespace google::protobuf;
120
 
 
121
118
  switch (m_type) {
122
119
  case QUERY:
123
120
  {
124
121
    Query *event= static_cast<Query*>(m_message);
125
122
    print_common(out, event);
126
 
    for (RepeatedPtrField<Query::Variable>::const_iterator ii= event->variable().begin() ;
 
123
    for (protobuf::RepeatedPtrField<Query::Variable>::const_iterator ii=
 
124
           event->variable().begin() ;
127
125
         ii != event->variable().end() ;
128
126
         ++ii)
129
127
    {
169
167
    break;                                      /* Nothing */
170
168
  }
171
169
}
 
170