Package org.apache.sis.storage.aggregate
Class JoinFeatureSet
java.lang.Object
org.apache.sis.storage.AbstractResource
org.apache.sis.storage.AbstractFeatureSet
org.apache.sis.storage.aggregate.AggregatedFeatureSet
org.apache.sis.storage.aggregate.JoinFeatureSet
- All Implemented Interfaces:
DataSet
,FeatureSet
,Resource
Features containing association to features from two different sources, joined by a SQL-like
JOIN
condition.
Each feature in this FeatureSet
contains two or three properties:
- An optional identifier created from the identifiers of the left and right features.
- Zero or one association to a "left" feature.
- Zero or one association to a "right" feature.
JoinFeatureSet
instance when a value from
leftProperty
in the first feature is equal to a value from rightProperty
in the second feature.
Implementation note
If iterations in one feature set is cheaper than iterations in the other feature set, then the "costly" or largerFeatureSet
should be on the left side and the "cheap" FeatureSet
should be on the right side.
This implementation is read-only.
- Since:
- 1.0
- Version:
- 1.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
Iterator over the features resulting from the inner or outer join operation.static enum
Specifies whether values on both sides are required (inner join), or only one side (outer join). -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BinaryComparisonOperator
<? super AbstractFeature> The join condition in the form property from left feature = property from right feature.private final DefaultFilterFactory
<AbstractFeature, ?, ?> The factory to use for creatingQuery
expressions for retrieving subsets of feature sets.private final boolean
Whether to include all "main" feature instances even if there is no match in the other side.final FeatureSet
The first source of features.private final String
Name of the associations to theleft
features.final FeatureSet
The second source of features.private final String
Name of the associations to theright
features.private final boolean
true
if the "main" side is the right side instead of the left side.private final DefaultFeatureType
The type of features included in this set.Fields inherited from class org.apache.sis.storage.AbstractResource
listeners
-
Constructor Summary
ConstructorsConstructorDescriptionJoinFeatureSet
(StoreListeners parent, FeatureSet left, String leftAlias, FeatureSet right, String rightAlias, JoinFeatureSet.Type joinType, BinaryComparisonOperator<? super AbstractFeature> condition, Map<String, ?> featureInfo) Creates a new feature set joining the two given sets. -
Method Summary
Modifier and TypeMethodDescription(package private) final List
<FeatureSet> Returns the two feature sets used by thisJoinFeatureSet
.features
(boolean parallel) Returns a stream of all features contained in this dataset.Specifies whether values on both sides are required (inner join), or only one side (outer join).getType()
Returns a description of properties that are common to all features in this dataset.private AbstractFeature
join
(AbstractFeature main, AbstractFeature filtered) Creates a new features containing an association to the two given features.Creates a minimalproperties
map for feature type or property type constructors.Methods inherited from class org.apache.sis.storage.aggregate.AggregatedFeatureSet
clearCache, createMetadata, getEnvelope
Methods inherited from class org.apache.sis.storage.AbstractFeatureSet
getFeatureCount, getIdentifier
Methods inherited from class org.apache.sis.storage.AbstractResource
addListener, getMetadata, getSynchronizationLock, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.sis.storage.FeatureSet
subset
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getMetadata, removeListener
-
Field Details
-
type
The type of features included in this set. Contains two associations as described in class javadoc. -
left
The first source of features. -
right
The second source of features. -
leftName
-
rightName
-
swapSides
private final boolean swapSidestrue
if the "main" side is the right side instead of the left side. SeeJoinFeatureSet.Iterator
for a definition of "main side". -
isOuterJoin
private final boolean isOuterJoinWhether to include all "main" feature instances even if there is no match in the other side. This istrue
for outer joins andfalse
for inner joins. -
condition
The join condition in the form property from left feature = property from right feature. This condition specifies also if the comparison is case sensitive and how to compare multi-values. -
factory
The factory to use for creatingQuery
expressions for retrieving subsets of feature sets.
-
-
Constructor Details
-
JoinFeatureSet
public JoinFeatureSet(StoreListeners parent, FeatureSet left, String leftAlias, FeatureSet right, String rightAlias, JoinFeatureSet.Type joinType, BinaryComparisonOperator<? super AbstractFeature> condition, Map<String, ?> featureInfo) throws DataStoreExceptionCreates a new feature set joining the two given sets. ThefeatureInfo
map defines the name, description or other information for theFeatureType
created by this method. It can contain all the properties described inDefaultFeatureType
plus the following ones:"identifierDelimiter"
— string to insert between left and right identifiers in the identifiers generated by the join operation. If this property is not specified, then no identifier will be generated."identifierPrefix"
— string to insert at the beginning of join identifiers (optional)."identifierSuffix"
— string to insert at the end of join identifiers (optional).
- Parameters:
parent
- listeners of the parent resource, ornull
if none.left
- the first source of features. This is often (but not necessarily) the largest set.leftAlias
- name of the associations to theleft
features, ornull
for a default name.right
- the second source of features. Should be the set in which iterations are cheapest.rightAlias
- name of the associations to theright
features, ornull
for a default name.joinType
- whether values on both sides are required (inner join), or only one side (outer join).condition
- join condition as property from left feature = property from right feature.featureInfo
- information about theFeatureType
of this feature set.- Throws:
DataStoreException
- if an error occurred while creating the feature set.
-
-
Method Details
-
name
Creates a minimalproperties
map for feature type or property type constructors. This minimalist map contain only the mandatory entry, which is the name. -
dependencies
Returns the two feature sets used by thisJoinFeatureSet
. The "main" dependency is at index 0 and the other dependency at index 1.- Specified by:
dependencies
in classAggregatedFeatureSet
- Returns:
- the dependencies in a list of size 2 with the "main" dependency first.
-
getJoinType
Specifies whether values on both sides are required (inner join), or only one side (outer join).- Returns:
- whether values on both sides are required (inner join), or only one side (outer join).
-
getType
Returns a description of properties that are common to all features in this dataset. This type may contain one identifier and always contains two associations, to the left andright
set of features respectively.- Returns:
- a description of properties that are common to all features in this dataset.
-
features
Returns a stream of all features contained in this dataset.- Parameters:
parallel
-true
for a parallel stream (if supported), orfalse
for a sequential stream.- Returns:
- all features contained in this dataset.
- Throws:
DataStoreException
- if an error occurred while creating the stream.
-
join
Creates a new features containing an association to the two given features. Themain
feature cannot be null (this is not verified).
-