Allow dialects to "smuggle" additional attributes in a query
------------------------------------------------------------

                 Key: GEOT-3537
                 URL: http://jira.codehaus.org/browse/GEOT-3537
             Project: GeoTools
          Issue Type: Improvement
          Components: data jdbc
            Reporter: Justin Deoliveira
            Assignee: Justin Deoliveira


Here is my problem, and it comes out of work for the Teradata jdbc datastore. 
In Teradata geometries are stored as blobs in the database. When a query such 
as the following happens:

{code}
SELECT the_geom FROM table ....
{code}

The jdbc driver does not return the actual geometry data but only a locator or 
identifier for it. And the jdbc code to access it is:

{code}
Blob b = rs.getBlob("the_geom");
{code}

Pretty standard. The problem is though that the jdbc driver has to make another 
trip to the server to retrieve the actual data for the blob. Which is expensive 
to do.

The workaround in teradata to get the blob data inline is to do a cast like the 
following:

{code}
SELECT CAST(the_geom AS VARBINARY(16000)) FROM table ....
{code}

Which forces the jdbc driver to coerce the blob into a byte array and return it 
inline, forgoing the need for a second query. Then the jdbc code to access is 
simply:


{code}
byte[] b = rs.getBytes("the_geom");
{code}

Now obviously this falls apart for large geometries since they can't be coerced 
into the byte array since it is too large. In this case the call to 
rs.getBytes() will simply return null.

So long story short my idea is to do this:

{code}
SELECT the_geom, CAST(the_geom AS VARBINARY(16000)) AS geom_inline FROM table 
....
{code}

And then the access code looks like this:

{code}

//first check for the inline geometry
byte[] b = rs.getBytes("the_geom_inline");

if (b == null) {
  //fall back to retrieving the blob from the server
  Blob blob = rs.getBlob("the_geom");
  ...
}
{code}

So the idea is to support the dialect smuggling additional columns into a 
SELECT. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to