Drizzled Public API Documentation

transaction_log_index.h

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 #pragma once
00032 
00033 #include "transaction_log.h"
00034 #include "transaction_log_entry.h"
00035 
00036 #include <pthread.h>
00037 #include <string>
00038 
00039 namespace drizzled { namespace message {class Transaction;}}
00040 
00041 class TransactionLogIndex
00042 {
00043 public:
00044   explicit TransactionLogIndex(TransactionLog &in_log);
00045   ~TransactionLogIndex();
00050   uint64_t getMinEndTimestamp() const;
00055   uint64_t getMaxEndTimestamp() const;
00060   uint64_t getMinTransactionId() const;
00065   uint64_t getMaxTransactionId() const;
00069   uint64_t getNumLogEntries() const;
00073   uint64_t getNumTransactionEntries() const;
00078   bool hasError() const;
00082   const std::string &getErrorMessage() const;
00087   TransactionLog::Entries &getEntries();
00092   TransactionLog::TransactionEntries &getTransactionEntries();
00100   void addEntry(const TransactionLogEntry &entry,
00101                 const drizzled::message::Transaction &transaction,
00102                 uint32_t checksum);
00111   void clear();
00112 
00113   /* Some methods returning size in bytes of the index and its parts */
00114   size_t getTransactionEntriesSizeInBytes();
00115   size_t getEntriesSizeInBytes();
00116   size_t getSizeInBytes();
00117 private:
00118   /* Don't allows these */
00119   TransactionLogIndex();
00120   TransactionLogIndex(const TransactionLogIndex &other);
00121   TransactionLogIndex &operator=(const TransactionLogIndex &other);
00126   void open();
00130   void clearError();
00131 
00132   TransactionLog &log; 
00133   int index_file; 
00134   const std::string index_file_path; 
00135   bool has_error; 
00136   std::string error_message; 
00137 
00138   uint64_t min_end_timestamp; 
00139   uint64_t max_end_timestamp; 
00140   uint64_t min_transaction_id; 
00141   uint64_t max_transaction_id; 
00142 
00143   TransactionLog::Entries entries; 
00144   TransactionLog::TransactionEntries transaction_entries; 
00145 
00146   pthread_mutex_t index_lock; 
00147 };
00148