Drizzled Public API Documentation

transaction_log_entry.cc

Go to the documentation of this file.
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2009 Sun Microsystems, Inc.
00005  *
00006  *  Authors:
00007  *
00008  *  Jay Pipes <joinfu@sun.com>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023  */
00024 
00031 #include <config.h>
00032 
00033 #include "transaction_log_entry.h"
00034 
00035 #include <drizzled/message/transaction.pb.h>
00036 
00037 #include <string>
00038 #include <map>
00039 
00040 using namespace std;
00041 using namespace drizzled;
00042 
00043 static const char *entry_type_names[]= 
00044 {
00045   "UNKNOWN",
00046   "TRANSACTION",
00047   "RAW BLOB"
00048 };
00049 
00050 TransactionLogEntry::TransactionLogEntry(enum ReplicationServices::MessageType in_type,
00051                                          off_t in_offset,
00052                                          size_t in_length) :
00053   type(in_type),
00054   offset(in_offset),
00055   length(in_length)
00056 {}
00057 
00058 TransactionLogEntry::~TransactionLogEntry()
00059 {}
00060 
00061 const char *TransactionLogEntry::getTypeAsString() const
00062 {
00063   return entry_type_names[type];
00064 }
00065 
00066 off_t TransactionLogEntry::getOffset() const
00067 {
00068   return offset;
00069 }
00070 
00071 size_t TransactionLogEntry::getLengthInBytes() const
00072 {
00073   return length;
00074 }
00075 
00076 TransactionLogTransactionEntry::TransactionLogTransactionEntry(off_t in_offset,
00077                                                                const message::Transaction &transaction,
00078                                                                uint32_t in_checksum) :
00079   offset(in_offset),
00080   server_id(transaction.transaction_context().server_id()),
00081   transaction_id(transaction.transaction_context().transaction_id()),
00082   start_timestamp(transaction.transaction_context().start_timestamp()),
00083   end_timestamp(transaction.transaction_context().end_timestamp()),
00084   num_statements(transaction.statement_size()),
00085   checksum(in_checksum)
00086 {
00087 }
00088 
00089 TransactionLogTransactionEntry::~TransactionLogTransactionEntry()
00090 {}
00091 
00092 off_t TransactionLogTransactionEntry::getOffset() const
00093 {
00094   return offset;
00095 }
00096 
00097 uint64_t TransactionLogTransactionEntry::getTransactionId() const
00098 {
00099   return transaction_id;
00100 }
00101 
00102 uint32_t TransactionLogTransactionEntry::getServerId() const
00103 {
00104   return server_id;
00105 }
00106 
00107 uint64_t TransactionLogTransactionEntry::getStartTimestamp() const
00108 {
00109   return start_timestamp;
00110 }
00111 
00112 uint64_t TransactionLogTransactionEntry::getEndTimestamp() const
00113 {
00114   return end_timestamp;
00115 }
00116 
00117 uint64_t TransactionLogTransactionEntry::getNumStatements() const
00118 {
00119   return num_statements;
00120 }
00121 
00122 uint32_t TransactionLogTransactionEntry::getChecksum() const
00123 {
00124   return checksum;
00125 }