~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/serialize/table_reader.cc

  • Committer: Brian Aker
  • Date: 2009-02-02 18:19:36 UTC
  • mfrom: (820.1.14 nofrm)
  • Revision ID: brian@tangent.org-20090202181936-l03a2jb3vpndr1k3
Merge from Stewart.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <sys/types.h>
 
2
#include <sys/stat.h>
 
3
#include <fcntl.h>
 
4
#include <string.h>
 
5
#include <stdio.h>
 
6
#include <errno.h>
 
7
 
1
8
#include <iostream>
2
 
#include <fstream>
3
9
#include <string>
4
10
#include <drizzled/serialize/table.pb.h>
 
11
#include <google/protobuf/io/zero_copy_stream.h>
 
12
#include <google/protobuf/io/zero_copy_stream_impl.h>
5
13
 
6
14
using namespace std;
7
15
using namespace drizzle;
 
16
using namespace google::protobuf::io;
8
17
 
9
18
/*
10
19
  Written from Google proto example
32
41
      int x;
33
42
 
34
43
      cout << " ENUM(";
35
 
      for (x= 0; x < field.set_options().value_size() ; x++)
 
44
      for (x= 0; x < field.set_options().field_value_size() ; x++)
36
45
      {
37
 
        const string type= field.set_options().value(x);
 
46
        const string type= field.set_options().field_value(x);
38
47
 
39
48
        if (x != 0)
40
49
          cout << ",";
114
123
 
115
124
  for (x= 0; x < engine.option_size(); ++x) {
116
125
    const Table::StorageEngine::EngineOption option= engine.option(x);
117
 
    cout << "\t" << option.name() << " = " << option.value() << endl;
 
126
    cout << "\t" << option.option_name() << " = "
 
127
         << option.option_value() << endl;
118
128
  }
119
129
}
120
130
 
156
166
 
157
167
  if (options.has_collation())
158
168
    cout << " COLLATE = '" << options.collation() << "' " << endl;
 
169
 
 
170
  if (options.has_auto_increment())
 
171
    cout << " AUTOINCREMENT_OFFSET = " << options.auto_increment() << endl;
 
172
 
 
173
  if (options.has_collation_id())
 
174
    cout << "-- collation_id = " << options.collation_id() << endl;
 
175
  
 
176
  if (options.has_connect_string())
 
177
    cout << " CONNECT_STRING = '" << options.connect_string() << "'"<<endl;
 
178
 
 
179
  if (options.has_row_type())
 
180
    cout << " ROW_TYPE = " << options.row_type() << endl;
 
181
 
 
182
/*    optional string data_file_name = 5;
 
183
    optional string index_file_name = 6;
 
184
    optional uint64 max_rows = 7;
 
185
    optional uint64 min_rows = 8;
 
186
    optional uint64 auto_increment_value = 9;
 
187
    optional uint32 avg_row_length = 11;
 
188
    optional uint32 key_block_size = 12;
 
189
    optional uint32 block_size = 13;
 
190
    optional string comment = 14;
 
191
    optional bool pack_keys = 15;
 
192
    optional bool checksum = 16;
 
193
    optional bool page_checksum = 17;
 
194
    optional bool delay_key_write = 18;
 
195
*/
159
196
}
160
197
 
161
198
 
180
217
    print_field(field);
181
218
  }
182
219
 
183
 
  for (x= 0; x < table.index_size() ; x++)
 
220
  for (x= 0; x < table.indexes_size() ; x++)
184
221
  {
185
 
    const Table::Index index= table.index(x);
 
222
    const Table::Index index= table.indexes(x);
186
223
 
187
224
    if (x != 0)
188
225
      cout << "," << endl;;
216
253
  Table table;
217
254
 
218
255
  {
219
 
    // Read the existing address book.
220
 
    fstream input(argv[1], ios::in | ios::binary);
221
 
    if (!table.ParseFromIstream(&input))
 
256
    int fd= open(argv[1], O_RDONLY);
 
257
 
 
258
    if(fd==-1)
 
259
    {
 
260
      perror("Failed to open table definition file");
 
261
      return -1;
 
262
    }
 
263
 
 
264
    ZeroCopyInputStream* input = new FileInputStream(fd);
 
265
 
 
266
    if (!table.ParseFromZeroCopyStream(input))
222
267
    {
223
268
      cerr << "Failed to parse table." << endl;
224
269
      return -1;