Package org.apache.sis.storage.aggregate
Class JoinFeatureSet.Iterator
java.lang.Object
org.apache.sis.storage.aggregate.JoinFeatureSet.Iterator
- All Implemented Interfaces:
Runnable,Consumer<AbstractFeature>,Spliterator<AbstractFeature>
- Enclosing class:
- JoinFeatureSet
private final class JoinFeatureSet.Iterator
extends Object
implements Spliterator<AbstractFeature>, Consumer<AbstractFeature>, Runnable
Iterator over the features resulting from the inner or outer join operation.
The
run() method disposes the resources.-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T extends Object,T_CONS extends Object, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AbstractFeatureA feature fetched from thefilteredIterator, ornullif none.private Spliterator<AbstractFeature>Iterator for thefilteredStream.private Stream<AbstractFeature>The stream over features in the other (usually right) side.private RunnableThe main stream or a split iterator to close when therun()method will be invoked.private AbstractFeatureA feature fetched from themainIterator.private final Spliterator<AbstractFeature>An iterator over all features in the "main" (usually left) side.Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Iterator()Creates a new iterator.privateCreates an iterator resulting from the call totrySplit(). -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(AbstractFeature feature) Callback forSpliterator.tryAdvance(this)onfilteredIterator.intSpecifies that the iterator will return only non-null elements.private voidInvoked when iteration on the filtered stream ended, before to move on the next feature of the main stream.private voidCreates a new iterator over the filtered set of features (usually the right side).longEstimated size is unknown.voidforEachRemaining(Consumer<? super AbstractFeature> action) Executes the given action on all remaining features in theJoinFeatureSet.voidrun()Closes the streams used by this iterator, together with the streams used by any spliterator created bytrySplit().booleantryAdvance(Consumer<? super AbstractFeature> action) Executes the given action on the next feature in theJoinFeatureSet.trySplit()If this iterator can be partitioned, returns a spliterator covering a prefix of the feature set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
mainCloseHandler
The main stream or a split iterator to close when therun()method will be invoked. This is initially the stream from whichmainIteratorhas been created. However, iftrySplit()has been invoked, then this handler may be the otherIteratorinstance which itself contains a reference to the stream to close, thus forming a chain. -
mainIterator
An iterator over all features in the "main" (usually left) side. The "main" side is the side which may include all features: in a "left outer join" this is the left side, and in a "right outer join" this is the right side. For inner join we arbitrarily take the left side in accordance with public class javadoc, which suggests to put the most costly or larger set on the left side.Only one iteration will be performed on those features, contrarily to the other side where we may iterate over the same elements many times.
-
mainFeature
A feature fetched from themainIterator. The join operation will match this feature with zero, one or more features from the other side. Anullvalue means that this feature needs to be retrieved withmainIterator.tryAdvance(…). -
filteredStream
The stream over features in the other (usually right) side. A new stream will be created every time a new feature from the main side is processed. For this reason, it should be the cheapest stream if possible. -
filteredIterator
Iterator for thefilteredStream. A new iterator will be recreated every time a new feature from the main side is processed. -
filteredFeature
A feature fetched from thefilteredIterator, ornullif none.
-
-
Constructor Details
-
Iterator
Iterator() throws DataStoreExceptionCreates a new iterator. We do not use parallelizedmainStreamhere because theaccept(…)methods used by thisIteratorcannot be invoked concurrently by different threads. It does not present parallelization at a different level since thisIteratorsupportstrySplit(), so theStreamwrapping it can use parallelization.- Throws:
DataStoreException
-
Iterator
Creates an iterator resulting from the call totrySplit().
-
-
Method Details
-
trySplit
If this iterator can be partitioned, returns a spliterator covering a prefix of the feature set. Upon return from this method, this iterator will cover a suffix of the feature set. Returnsnullif this iterator cannot be partitioned.- Specified by:
trySplitin interfaceSpliterator<AbstractFeature>
-
characteristics
public int characteristics()Specifies that the iterator will return only non-null elements. Whether those elements will be ordered depends on whether the main iterator provides ordered elements in the first place.NOTE: to be strict, we should check if the "filtered" stream is also ordered. But this is more difficult to check. Current implementation assumes that if the "mean" stream is ordered, then the other stream is ordered too. Furthermore, the
trySplit()method works only on the main stream, so at least thetrySplitrequirement about prefix and suffix order is still fulfill even if the other stream is unordered.- Specified by:
characteristicsin interfaceSpliterator<AbstractFeature>
-
estimateSize
public long estimateSize()Estimated size is unknown.- Specified by:
estimateSizein interfaceSpliterator<AbstractFeature>
-
run
public void run()Closes the streams used by this iterator, together with the streams used by any spliterator created bytrySplit(). This method is registered toBaseStream.onClose(Runnable). -
closeFilteredIterator
private void closeFilteredIterator()Invoked when iteration on the filtered stream ended, before to move on the next feature of the main stream. This method is idempotent: it has no effect if the stream is already closed. -
createFilteredIterator
private void createFilteredIterator()Creates a new iterator over the filtered set of features (usually the right side). The filtering condition is determined by the currentmainFeature. -
forEachRemaining
Executes the given action on all remaining features in theJoinFeatureSet.- Specified by:
forEachRemainingin interfaceSpliterator<AbstractFeature>
-
accept
Callback forSpliterator.tryAdvance(this)onfilteredIterator. Used bytryAdvance(Consumer)implementation only.- Specified by:
acceptin interfaceConsumer<AbstractFeature>
-
tryAdvance
Executes the given action on the next feature in theJoinFeatureSet.- Specified by:
tryAdvancein interfaceSpliterator<AbstractFeature>
-