pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Julian Scarfe <jscarfe@callnetuk.com>
To: selkovjr@mcs.anl.gov
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Paths in DBD::Pg
Date: Tue, 18 May 1999 10:01:43 +0100
Message-ID: <37412C77.B1002B62@callnetuk.com> (raw)
References: <199905161628.LAA13696@antares.mcs.anl.gov>

selkovjr@mcs.anl.gov wrote:
> 
> > I'd like to deal with geometrical data types, paths in particular,
> > efficiently in Perl using Pg. But Pg, understadably I suppose, just
> > returns a path as a scalar string like ((1,2),(3,4),(5,6)). Whereas
> > I can 'eval' a point fairly efficiently, it's not very efficient to
> > turn a long string such as the above into an array of arrays.
> 
> You don't need to eval() individual points. If you eval() the whole
> thing it will give you one single array:
> 
> @a = eval "((1,2),(3,4),(5,6))";
> print "@a\n";

Sorry, the question wasn't very clear.  For subsequent processing I need
the path as an array of two-element array references representing
individual points. At the moment I have a choice of:

eval-ing the path into a flat array and then shifting them 2-by-2 into a
suitable structure

tr-ing the ()s into []s to make [[1,2],[3,4],[5,6]] and them eval-ing
that.

The tr-route is marginally quicker, but both feel inefficient and take a
significant part of my processing time for paths of significant length. 
If there's nothing built into Pg for pulling out the structure in one
go, I suppose it's time to get perlguts out... ;-)

Julian






view thread (4+ messages)  latest in thread

Message-ID: <37412C77.B1002B62@callnetuk.com>
Permalink:  ../37412C77.B1002B62@callnetuk.com/
Also on:    postgresql.org/message-id/37412C77.B1002B62@callnetuk.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jscarfe@callnetuk.com, selkovjr@mcs.anl.gov
  Subject: Re: [INTERFACES] Paths in DBD::Pg
  In-Reply-To: <37412C77.B1002B62@callnetuk.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox