views:

37

answers:

2

I need to parse a large trace file (up to 200-300 MB) in a Flex application. I started using JSON instead of XML hoping to avoid these problems, but it did not help much. When the file is bigger than 50MB, JSON decoder can't handle it (I am using the as3corelib).

I have doing some research and I found some options:

  • Try to split the file: I would really like to avoid this; I don't want to change the current format of the trace files and, in addition, it would be very uncomfortable to handle.
  • Use a database: I was thinking of writing the trace into a SQLite database and then reading from there, but that would force me to modify the program that creates the trace file.

From your experience, what do you think of these options? Are there better options?

The program that writes the trace file is in C++.

+2  A: 

Using AMF will give you much smaller data sizes for transfer because it is a binary, not text format. That is the best option. But, you'll need some middleware to translate the C++ program's output into AMF data.

Check out James Ward's census application for more information about benchmarks when sharing data:

http://www.jamesward.com/census/ http://www.jamesward.com/2009/06/17/blazing-fast-data-transfer-in-flex/

www.Flextras.com
I had looked into AMF and it seems intended to create communications between a client and a server, not as a trace file format.In addition, I really want to avoid middleware... And the file size is not a problem, the problem is whether I am able to parse it or not.
miguelSantirso
AMF is for communications between 2 systems; which is exactly what you're trying to do. Most, if not all, of the existing AMF uses are for client server, though. In theory you could write your own AMF serializer. That said, how is your trace file being sourced? It is created with a C++ program. Is C++ passing it to Flex? Or is Flex reading it off the hard drive somewhere?
www.Flextras.com
+1  A: 

Maybe you could parse the file into chunks, without splitting the file itself. That supposes some work on the as3 core lib Json parser, but it should be doable, I think.

Axelle Ziegler
I had thought of doing that, and can be a good idea... But, to do that I would need to do searches in a huge string (to know where is the beginning of each chunk). Do you think that will be fast enough?
miguelSantirso
I'm not sure, but yeah, simply splitting a string after a given number of '{' and '}' shoud be faster than doing the whole parsing stuff, depending on the structure of your file. It's at the very least worth a try I guess.
Axelle Ziegler