You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/06/29 21:33:03 UTC
svn commit: r1800331 -
/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
Author: schor
Date: Thu Jun 29 21:33:03 2017
New Revision: 1800331
URL: http://svn.apache.org/viewvc?rev=1800331&view=rev
Log:
support stream of non-empty indexes
Modified:
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1800331&r1=1800330&r2=1800331&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Thu Jun 29 21:33:03 2017
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.function.Consumer;
+import java.util.stream.Stream;
import org.apache.uima.UIMARuntimeException;
import org.apache.uima.cas.CAS;
@@ -1522,6 +1523,33 @@ public class FSIndexRepositoryImpl imple
}
// ((TypeImpl)type).getDirectSubtypes().stream().forEach(subType -> getAllIndexedFS(subType, iteratorList));
}
+
+
+ public Stream<FsIndex_singletype<FeatureStructure>> streamNonEmptyIndexes(Type type) {
+ TypeImpl ti = (TypeImpl) type;
+ if (!isUsed.get(ti.getCode())) {
+ return streamNonEmptyDirectSubtypes(ti);
+ }
+ FsIndex_iicp<TOP> iicp = getIndexesForType(ti.getCode()).getNonSetIndex();
+ if (null == iicp || iicp.isEmpty()) {
+ return Stream.empty();
+ }
+ Stream<FsIndex_singletype<FeatureStructure>> iicpIndexesStream = iicp.streamNonEmptyIndexes();
+ return iicp.isDefaultBagIndex()
+ ? Stream.concat(iicpIndexesStream, streamNonEmptyDirectSubtypes(ti))
+ : iicpIndexesStream;
+ }
+
+ public Stream<FsIndex_singletype<FeatureStructure>> streamNonEmptyDirectSubtypes(TypeImpl ti) {
+ Stream<FsIndex_singletype<FeatureStructure>> r = null;
+ for (TypeImpl subType : ti.getDirectSubtypes()) {
+ r = (r == null)
+ ? streamNonEmptyIndexes(subType)
+ : Stream.concat(r, streamNonEmptyIndexes(subType));
+ }
+ return (r == null) ? Stream.empty() : r;
+ }
+
// next method dropped - rather than seeing if something is in the index, and then
// later removing it (two lookups), we just conditionally remove it