pradeepgv42 commented on a change in pull request #6120:
URL: https://github.com/apache/incubator-pinot/pull/6120#discussion_r524475098



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/util/fst/RegexpMatcher.java
##########
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.util.fst;
+
+import org.apache.lucene.util.IntsRefBuilder;
+import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.CharacterRunAutomaton;
+import org.apache.lucene.util.automaton.RegExp;
+import org.apache.lucene.util.automaton.Transition;
+import org.apache.lucene.util.fst.FST;
+import org.apache.lucene.util.fst.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class RegexpMatcher {

Review comment:
       Added, let me know if should expand

##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/util/fst/RegexpMatcher.java
##########
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.util.fst;
+
+import org.apache.lucene.util.IntsRefBuilder;
+import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.CharacterRunAutomaton;
+import org.apache.lucene.util.automaton.RegExp;
+import org.apache.lucene.util.automaton.Transition;
+import org.apache.lucene.util.fst.FST;
+import org.apache.lucene.util.fst.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class RegexpMatcher {
+    public static final Logger LOGGER =
+            LoggerFactory.getLogger(FSTBuilder.class);
+
+    private final String _regexQuery;
+    private final FST<Long> _fst;
+    private final Automaton _automaton;
+
+    public RegexpMatcher(String regexQuery, FST<Long> fst) {
+        _regexQuery = regexQuery;
+        _fst = fst;
+        _automaton = (new RegExp(_regexQuery)).toAutomaton();
+
+    }
+
+    public static final class Path<T> {
+        public final int state;
+        public final FST.Arc<T> fstNode;
+        public final T output;
+        public final IntsRefBuilder input;
+
+        public Path(int state, FST.Arc<T> fstNode, T output, IntsRefBuilder 
input) {
+            this.state = state;
+            this.fstNode = fstNode;
+            this.output = output;
+            this.input = input;
+        }
+    }
+
+    // Matches "input" string with _regexQuery Automaton.
+    public boolean match(String input) {
+        CharacterRunAutomaton characterRunAutomaton =
+                new CharacterRunAutomaton(_automaton);
+        return characterRunAutomaton.run(input);
+    }
+
+    public static List<Long> regexMatch(String regexQuery, FST<Long> fst) 
throws IOException {
+        RegexpMatcher matcher = new RegexpMatcher(regexQuery, fst);
+        return matcher.regexMatchOnFST();
+    }
+
+    public List<Long> regexMatchOnFST() throws IOException {

Review comment:
       Added, let me know if should expand
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to