You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/12/12 11:31:53 UTC

[GitHub] [iotdb] MarcosZyk commented on a diff in pull request #8400: [IOTDB-5168] Refactor traverse of AbstractTreeVisitor to FA-based traverse

MarcosZyk commented on code in PR #8400:
URL: https://github.com/apache/iotdb/pull/8400#discussion_r1045711530


##########
node-commons/src/main/java/org/apache/iotdb/commons/path/fa/SimpleNFA.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.iotdb.commons.path.fa;
+
+import org.apache.iotdb.commons.path.PartialPath;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import static org.apache.iotdb.commons.conf.IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD;
+import static org.apache.iotdb.commons.conf.IoTDBConstant.ONE_LEVEL_PATH_WILDCARD;
+
+/**
+ * Given path pattern root.sg.*.s, the SimpleNFA is:
+ *
+ * <p>initial -(root)-> state[0] -(sg)-> state[1] -(*)-> state[2] -(s)-> state[3] <br>
+ * state[3] is final state
+ *
+ * <p>Given path pattern root.**.d.s, the SimpleNFA is:
+ *
+ * <p>initial -(root)-> state[0] -(*)-> state[1] -(d)-> state[2] -(s)-> state[3] <br>
+ * with extra: state[2] -(*)-> state[1] <br>
+ * state[3] is final state
+ *
+ * <p>Given path pattern root.sg.d with prefix match, the SimpleNFA is:
+ *
+ * <p>initial -(root)-> state[0] -(sg)-> state[1] -(d)-> state[2] -(*)-> state[3] <br>
+ * both state[2] and state[3] are final states
+ */
+public class SimpleNFA implements IPatternFA {
+
+  // raw nodes of pathPattern
+  private final String[] nodes;
+
+  // used for pattern node like d*
+  private final Map<Integer, Pattern> regexPatternMap = new HashMap<>();
+
+  // initial state of this NFA and the only transition from this state is "root"
+  private final SimpleNFAState initialState = new SimpleNFAState(-1);
+  // all states corresponding to raw pattern nodes, with an extra prefixMatch state
+  private final SimpleNFAState[] states;
+
+  // singletonMap, "root"
+  private final Map<String, IFATransition> initialTransition;
+  // the transition matches only specific value
+  private final Map<String, IFATransition>[] preciseMatchTransitionTable;

Review Comment:
   Description added.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

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