views:

1734

answers:

3

i am developping a little app that retrieves an XML file, located on a remote server (http://xxxx.com/myfile.xml) This file is relatively big, and it contains a big list of geolocations with other informations that i need to use for my app. So i read this file remotely once and insert it into a little SqlCE file (database.sdf)

So If I need to be accessing geolocation #1, i ll just make a SELECT statement into this DATABASE instead of loading the whole XML file everytime.

But i would like to know if its possible to do this without using .sdf files ?

What is the most efficient way (fastest)?

Saving the big XML file once locally and load if everytime i start my app to load it in a dataset ? this is would make the app a bit long to load everytime

Saving the big XML file once locally and reading the nodes one by one to look for geolocation #1 ?

Or is it possible to retrieve geolocation #1 from the remote xml directly(http://xxxx.com/myfile.xml) without reading the whole file ?

Do you have any other ideas?

thanks

+2  A: 

Load the big XML file, convert it into an appropriate different data structure, save it to a file in an efficient format. (XML really isn't terribly efficient.)

I believe Marc Gravell's Protocol Buffers implementation works on the Compact Framework...

(None of the protobuf implementations are deemed production-ready yet, but a couple are close. We need testers!)

Jon Skeet
Thanks, this seems interesting. But i cannot find the Compact Framework version (only found 2/3/Silver).So if i understood well, this "Protocol Buffers" is used to encode structured data into a ".prot" file?But then is would mean i still have to load this .prot file everytime i start the app ?
guigui42
Protocol Buffers is basically a binary serialization protocol. Yes, you'd need to load the file - but it would be small (the PB is efficient in space) and fast (PB parsers are efficient in time). Unless you feel like changing the assembly itself, you're going to have to load the data from somewhere!
Jon Skeet
+1  A: 

Re protobuf-net, there isn't a separate download for the CF version at the moment, but there is a csproj in the source for both CF 2.0 and CF 3.5.

To clarify on your question; actually protobuf-net doesn't even use a .proto file (at the moment); a .proto file just describes what the data is - protobuf-net simply looks at your classes and infers the schema from that (similar to how XmlSerializer / DataContractSerializer etc work). So there is not .proto - just the classes that look like your data.

However, before you embark on creating classes that look like your data, I wonder if you couldn't simply use GZIP or [PK]ZIP to compress the data, and transfer it "as is". Xml generally compresses very well. Of course, finding a GZIP (etc) implementation for CF then becomes the issue.

Of course, if you want to use protobuf-net here, I'll happily advise etc if you get issues...

The other option is for your CF app to call into a web-service that has the data locally...

Marc Gravell
thanks a lot for the informations.Actually, speed is my biggest concern, not size (speed for loading the app, and retrieving geolocation #X from the file).And from what i read on the performances, protobuf-net should do the trick. PS: i am using CF.NET 3.5,
guigui42
That's good; the CF 3.5 version has some optimisations (to do with delegates) that the CF 2.0 version can't use.
Marc Gravell
So far... i love ProtoBuf ... i m only testing on my desktop so far, but its quite easy to use (with the exemple in the SVN Trunk). I still have to try with CF.NET yet, but it seems its exactly what i needed.Great work !
guigui42
I'm pleased you're getting on OK with it. If you get any issues, drop me a line, either by e-mail (I'me easy to find...) or via the PB site.
Marc Gravell
A: 

Why would you pull the entire file down to the CE device for this? It's a bandwidth waste and certainly doing the lookup on an embedded processor is going to be way slower than on the server regardless of storage format. You should have a service (Web, WCF or whatever) that allows you to ask it for the single geolocation you want.

ctacke
yes, i wished there was a webservice... but the XML file is not generated by me, its from a third party.So until they create a webservice, i m stuck with that solution.But the Protocol Buffer is so far the best alternative i have tried (faster than sdf file or parsing xml everytime)
guigui42