I have message defined as
message Person
  required int32 id;

and than, after protoc-compiling I dump 500 Million of such buffers
using a c++ application into a file.

Now, when I read it back using a different C++ application (and
ParseFromIoStream, I get an error "message too long and look at the
file ..."

My intended behavior is to read the pb-message one at a time, analyze
its content and than read next message. For some reason. when I
deseralize from iostream, pb is reading and deseralizing full content
of the file.

How can I make the deserialization to work online, one message at a
time from the IoStream.

My code is attached below.

Many Thanks, Amit

#include <stdio.h>
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include "temp.pb.h"

using namespace std;

#define MAX 500000000

void write()
  fstream output("out.db", ios::out | ios::trunc | ios::binary);

  for(int num = 0; num < MAX; ++num)
    Person p;

void read()
  fstream input("out.db", ios::in  | ios::binary);

  int num = 0;
  for(; num < MAX; ++num)
    Person p;
  cout << endl << num << endl;

int main()
  //cout << "Done Writing";
  cout << "Done reading" << endl;
  return 0;

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to