~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/transaction_log/utilities/transaction_file_reader.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2010 David Shrewsbury <shrewsbury.dave@gmail.com>
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
/**
21
 
 * @file
22
 
 * Declaration of a class used to read the GPB messages written
23
 
 * by transaction_writer.
24
 
 */
25
 
 
26
 
#pragma once
27
 
 
28
 
#include <string>
29
 
#include <google/protobuf/io/zero_copy_stream_impl.h>
30
 
#include <drizzled/message/transaction.pb.h>
31
 
 
32
 
class TransactionFileReader
33
 
{
34
 
public:
35
 
  TransactionFileReader();
36
 
  ~TransactionFileReader();
37
 
 
38
 
  /**
39
 
   * Open the given transaction log file.
40
 
   *
41
 
   * @param filename Name of the file to open
42
 
   * @param start_pos Position within the file to begin reading
43
 
   *
44
 
   * @retval true Success
45
 
   * @retval false Failure
46
 
   */
47
 
  bool openFile(const std::string &filename, int start_pos = 0);
48
 
 
49
 
  /**
50
 
   * Read in next Transaction message and checksum.
51
 
   *
52
 
   * @note Error message will be "EOF" when end-of-file is reached.
53
 
   *
54
 
   * @param transaction Storage for the Transaction message
55
 
   * @param checksum Storage for the checksum value
56
 
   *
57
 
   * @retval true Success
58
 
   * @retval false Failure or EOF
59
 
   */
60
 
  bool getNextTransaction(drizzled::message::Transaction &transaction,
61
 
                          uint32_t *checksum);
62
 
 
63
 
  /**
64
 
   * Perform a checksum of the last read transaction message.
65
 
   */
66
 
  uint32_t checksumLastReadTransaction();
67
 
 
68
 
  /**
69
 
   * Get the error message from the last failed operation.
70
 
   */
71
 
  std::string getErrorString()
72
 
  {
73
 
    return error;
74
 
  }
75
 
 
76
 
private:
77
 
  int file;
78
 
  char *buffer;
79
 
  char *temp_buffer;
80
 
  uint32_t previous_length;
81
 
  std::string error;
82
 
  google::protobuf::io::ZeroCopyInputStream *raw_input;
83
 
};
84