Github user dsmiley commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/129#discussion_r94244009
--- Diff:
lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java
---
@@ -80,22 +77,41 @@ public boolean incrementToken() throws IOException {
}
}
+ private GraphTokenStreamFiniteStrings() {
+ this.builder = new Automaton.Builder();
+ }
+
/**
* Gets the list of finite string token streams from the given input
graph token stream.
*/
- public List<TokenStream> getTokenStreams(final TokenStream in) throws
IOException {
- // build automation
+ public static List<TokenStream> getTokenStreams(final TokenStream in)
throws IOException {
+ GraphTokenStreamFiniteStrings gfs = new
GraphTokenStreamFiniteStrings();
+ return gfs.process(in);
+ }
+
+ /**
+ * Builds automaton and builds the finite string token streams.
+ */
+ private List<TokenStream> process(final TokenStream in) throws
IOException {
build(in);
List<TokenStream> tokenStreams = new ArrayList<>();
final FiniteStringsIterator finiteStrings = new
FiniteStringsIterator(det);
for (IntsRef string; (string = finiteStrings.next()) != null; ) {
final BytesRef[] tokens = new BytesRef[string.length];
--- End diff --
Hmm; rather than materializing an array of tokens and increments, maybe you
could simply give the IntsRefString to BytesRefArrayTokenStream (and make
BRATS not static) so that it could do this on the fly? Not a big deal either
way (current or my proposal). If you do as I suggest then BRATS would no
longer be a suitable name; maybe simply FiniteStringTokenStream or
CustomTokenStream.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]