richardstartin commented on a change in pull request #7405:
URL: https://github.com/apache/pinot/pull/7405#discussion_r710152910



##########
File path: 
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/nativefst/FSTTestUtils.java
##########
@@ -0,0 +1,129 @@
+/**
+ * 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.segment.local.utils.nativefst;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import org.apache.pinot.segment.local.utils.nativefst.builders.FSTBuilder;
+import org.apache.pinot.segment.local.utils.nativefst.utils.RegexpMatcher;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.testng.Assert.assertEquals;
+import static org.testng.FileAssert.fail;
+
+
+/**
+ * Test utils class
+ */
+class FSTTestUtils {
+
+  private FSTTestUtils() {
+  }
+
+  /*
+   * Generate a sorted list of random sequences.
+   */
+  public static byte[][] generateRandom(int count, MinMax length, MinMax 
alphabet) {
+    final byte[][] input = new byte[count][];
+    final Random rnd = new Random();
+    for (int i = 0; i < count; i++) {
+      input[i] = randomByteSequence(rnd, length, alphabet);
+    }
+    Arrays.sort(input, FSTBuilder.LEXICAL_ORDERING);
+    return input;
+  }
+
+  /**
+   * Generate a random string.
+   */
+  private static byte[] randomByteSequence(Random rnd, MinMax length, MinMax 
alphabet) {
+    byte[] bytes = new byte[length._min + rnd.nextInt(length.range())];
+    for (int i = 0; i < bytes.length; i++) {
+      bytes[i] = (byte) (alphabet._min + rnd.nextInt(alphabet.range()));
+    }
+    return bytes;

Review comment:
       I have experienced wildly different results benchmarking string search 
algorithms on uniformly random input and inputs generated by Markov processes 
with transition probabilities inferred from large texts: [I wrote about it 
here](https://richardstartin.github.io/posts/heuristics-for-substring-search#markov-chain-generated-english-and-german).
 I would suggest sourcing some natural language text to measure this.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to