PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > advise needed: storing huge structure persistent or alternative approach
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
advise needed: storing huge structure persistent or alternative approach

Réponse
 
LinkBack Outils de la discussion
Vieux 12/07/2007, 12h51   #1
busnet
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut advise needed: storing huge structure persistent or alternative approach

Hi.
I've got the following problem: I have a huge xml-file that represents
a street map of a city. Each street is stored as a couple of
coordinates (start, end and all the turns).
When I set a marker in a google map, I want to find all streets that
are near this marker position.
I now parse the whole file as a simpleXML object, and calculate the
distances to each street segment (using linear algebra algorithms,
that is, constructing the vector from two points and computing the
distance from the given point to this vector).
Up to now it works like this: I set a marker and the gmaps method
"gdownload()" calls a server side php script, which
1. reads the xml file into an simplexml object
2. for every two coordinates that belong to the same street, it
calculates the vector and computes its distance to the point
3. returns the nearest x streets (as polylines) back to the client

It repeats this, when I set the next marker.

Problems/need for ideas:
1) It always reads the XML file anew, when I set another marker. Is
there some way to cache this or a more intelligent approach? I tried
saving the whole Simplexml-object in a session variable, but it was
too huge. I guess I could create some tables in mysql, but I'm not
sure thats the best solution yet.
2) Not php-specific: Do you have any ideas how to speed up the process
of finding the nearest lane(s)? I tried to consider only those streets
whose endpoints are within a certain range from the given marker-
point, but it was not considerably faster and if there was a street
thats very long and straight the endpoints may be far away, but the
street itself is quite near.

  Réponse avec citation
Vieux 12/07/2007, 13h19   #2
Sebastiaan 'CrashandDie' Lauwers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: advise needed: storing huge structure persistent or alternativeapproach

busnet wrote:
> Hi.


Hi,

> Problems/need for ideas:
> 1) It always reads the XML file anew, when I set another marker. Is
> there some way to cache this or a more intelligent approach? I tried
> saving the whole Simplexml-object in a session variable, but it was
> too huge. I guess I could create some tables in mysql, but I'm not
> sure thats the best solution yet.


Serialize () the simpleXML-object, and save that in a text file ?

On load, $xmlSimpleObject = unserialize (file_get_contents ()) ?

Dunno if it's faster, but it just might be.

> 2) Not php-specific: Do you have any ideas how to speed up the process
> of finding the nearest lane(s)? I tried to consider only those streets
> whose endpoints are within a certain range from the given marker-
> point, but it was not considerably faster and if there was a street
> thats very long and straight the endpoints may be far away, but the
> street itself is quite near.


Can't you with that, sorry.

HTH,

S/
  Réponse avec citation
Vieux 13/07/2007, 11h41   #3
Sebastiaan 'CrashandDie' Lauwers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: advise needed: storing huge structure persistent or alternativeapproach

busnet wrote:

> I also thought about that, but it wont be that much faster, I'm
> afraid. A file still has to be read every time.


Not exactly.

It is possible to store a file in the RAM (copy would have to be saved
regularly on the disk so to not lose the contents if there was a
failure, but still).

What I mean is, that a good operating system, is going to cache the
files that are under heavy access. GNU/Linux can do this, if the kernel
is of a decent flavour. I recall the Debian one doing it without any
problems.

Also, hacking the operating system quite severely, I'm pretty sure it
should be experimentally possible to map the RAM, and allocate some
place you could mount, as such, you would have a very sharp and fast
memory, that would keep any kind of files stored for at least some time,
and reload it, if it hasn't been accessed in a given amount of time.

A last solution, I guess, would be to fork () the application, and keep
one part of the application running in the background, keeping all the
variables and objects in RAM, and trying to get those values back, one
way or another.

Doing this like this, you might in fact be bothered, as PHP has a max
execution time of 45 seconds (default value), and that isn't
specifically *long* ! As such, it might just be easier to run a daemon
in whatever language, (be it PHP, C, C++), and that would act as a
server, you could query easily. The daemon could be started up by the
PHP script, if it is run, and there is no answer, a small exec () and
there you go...

These are all pretty random ideas, I can try to elaborate one of these
if you are interested.

> Thanks anyway.


HTH,

S.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 21h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09937 seconds with 11 queries