Hi Andrea,
I'm not sure if I understand your situation correctly.. I might've misunderstood.
Do you have up to 10 container-attribute per feature (depending on how the database entries), or is it pre-determined?
If it's the first case, you can't do it without feature chaining.
If it's the second case, you can map each container attribute easily.
E.g. If you are to have 3 container-att per feature (and it's consistent across features), that would look like this:
<feature>
<container-att1>
<subatt1.1>...
<subatt1.2>...
<repeated-subatt1>...</repated-subatt1>
<repeated-subatt1>...</repated-subatt1>
<repeated-subatt1>...</repated-subatt1>
</container-att1>
<container-att1>
<subatt2.1>...
<repeated-subatt2>...</repated-subatt2>
<repeated-subatt2>...</repated-subatt2>
<repeated-subatt2>...</repated-subatt2>
</container-att1>
<container-att3>
<repeated-subatt3 att="one">...</repated-subatt3>
<repeated-subatt3 att="two">...</repated-subatt3>
<repeated-subatt3 att="three">...</repated-subatt3>
</container-att1>
You can map it like this, without firing unnecessary sub-queries:
<FeatureTypeMapping>
<sourceDataStore>some_database</sourceDataStore>
<sourceType>some_denormalised_table</sourceType>
<targetElement>feature</targetElement>
<attributeMappings>
<!-- Option#1, separate mapping -->
<AttributeMapping>
<targetAttribute>container-att1</targetAttribute>
<sourceExpression><linkElement>subatts1</linkElement></sourceExpression>
</AttributeMapping>
<!-- Option#2, inline mapping -->
<AttributeMapping>
<targetAttribute>subatt2.1</targetAttribute>
<sourceExpression><OCQL>SUB_ATT2.1</OCQL></sourceExpression>
</AttributeMapping>
<AttributeMapping>
<targetAttribute>repeated-subatt2</targetAttribute>
<sourceExpression><OCQL>REPEATED_SUB_ATT2</OCQL></sourceExpression>
<isMultiple>true</isMultiple>
</AttributeMapping>
<!-- Separate mapping again -->
<AttributeMapping>
<targetAttribute>container-att3</targetAttribute>
<sourceExpression><linkElement>subatts3</linkElement></sourceExpression>
</AttributeMapping>
</attributeMappings>
</FeatureTypeMapping>
<!-- Referred by container-att1 -->
<FeatureTypeMapping>
<mappingName>subatts1</mappingName>
<sourceDataStore>some_database</sourceDataStore>
<sourceType>some_denormalised_table</sourceType>
<targetElement>sub_feature</targetElement>
<attributeMappings>
<AttributeMapping>
<targetAttribute>subatt1.1</targetAttribute>
<sourceExpression><OCQL>SUB_ATT1.1</OCQL></sourceExpression>
</AttributeMapping>
<AttributeMapping>
<targetAttribute>subatt1.2</targetAttribute>
<sourceExpression><OCQL>SUB_ATT1.2</OCQL></sourceExpression>
</AttributeMapping>
<AttributeMapping>
<targetAttribute>repeated-subatt1</targetAttribute>
<sourceExpression><OCQL>REPEATED_SUB_ATT1</OCQL></sourceExpression>
<isMultiple>true</isMultiple>
</AttributeMapping>
</attributeMappings>
</FeatureTypeMapping>
<!-- Referred by container-att3 -->
<FeatureTypeMapping>
<mappingName>subatts3</mappingName>
<sourceDataStore>some_database</sourceDataStore>
<sourceType>some_denormalised_table</sourceType>
<targetElement>sub_feature</targetElement>
<attributeMappings>
<AttributeMapping>
<targetAttribute>repeated-subatt3</targetAttribute>
<sourceExpression><OCQL>SUB_ATT3_COLUMN</OCQL></sourceExpression>
<isMultiple>true</isMultiple>
<ClientProperty>
<name>att</name>
<value>Recode(SOME_CONDITIONAL_COLUMN, 1, "one", 2, "two", 3, "three")</value>
<ClientProperty>
</AttributeMapping>
</attributeMappings>
</FeatureTypeMapping>
But it seems to me, you don't know how many container attributes exist per feature, so this won't work.
Re: CQL functions in app-schema. No, app-schema is not smart enough to turn them into native filters.
The functions are treated as Expression, and is evaluated against every SimpleFeature (database entry) when building a complex feature.
So in the end it just gets a column value that's already there, with no additional queries executed.
Cheers
Rini
----------------------------------------------------------------------
Message: 1
Date: Fri, 1 Oct 2010 09:32:47 +0200
From: Andrea Aime <andrea.aime@anonymised.com>
Subject: [Geoserver-devel] Efficiently dealing with multiple
multivalued attributes in app-schema
To: geoserver-devel@lists.sourceforge.net
Message-ID:
<AANLkTimnjEaHDxJR7izrn1cYuTM2fWfTWComX16KBFvE@anonymised.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I'm dealing with an application schema that has a number of
subelements in the form:
<container-attribute>
<someAttribute>...</someAttribute>
<repeated>one</repeated>
<repeated>two</repeated>
<repeated>three</repeated>
...
</container-attribute>
Imagine a situation where the main type has something like 10 of those
sub-attributes.
If I go and use feature chaining that will result in 10 sub-queries
for each returned
main query. That is probably not acceptable performance wise (as in,
unusable in practical
terms when one has tens of millions of records and the typical query
extracts some hundreds
or records, resulting in app-schema making some thousands of queries
per GetFeature request).
I was wondering if those lists of keywords can be stored in a single
attribute instead, and
unpacked in memory using a CQL expression that turns a comma separate
list into a list of
values (something like a split function to parse them, but also able
to deal with escape chars).
Is that going to work at all?
Also, I noticed that the guide suggest the usage of some functions
such as vocabolaries
and the like. Is the store smart enough to invert well known functions
and turn them into
a native filter?
Was wondering if it's also possible to teach the store to treat a
xpath like /container/attribute/repeated=two
and turn it into a sql looking like "attribute_repeated like
'%,two,%', if you get the idea
Cheers
Andrea
-----------------------------------------------------
Ing. Andrea Aime
Senior Software Engineer
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 ?Massarosa (LU)
Italy
phone: +39 0584962313
fax: ? ? +39 0584962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-----------------------------------------------------