markrmiller commented on a change in pull request #214:
URL: https://github.com/apache/solr/pull/214#discussion_r672487028



##########
File path: solr/test-framework/src/jmh/org/apache/solr/bench/DocMakerRamGen.java
##########
@@ -0,0 +1,269 @@
+/*
+ * 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.solr.bench;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.Validate;
+import org.apache.lucene.util.TestUtil;
+import org.apache.solr.common.SolrInputDocument;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Queue;
+import java.util.Random;
+import java.util.SplittableRandom;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class DocMakerRamGen {
+
+  private final static Map<String,Queue<SolrInputDocument>> CACHE = new 
ConcurrentHashMap<>();
+
+  private Queue<SolrInputDocument> docs = new ConcurrentLinkedQueue<>();
+
+  private final Map<String, FieldDef> fields = new HashMap<>();
+
+  private static final AtomicInteger ID = new AtomicInteger();
+  private final boolean cacheResults;
+
+  private ExecutorService executorService;
+
+  private SplittableRandom threadRandom;
+
+  public DocMakerRamGen() {
+   this(true);
+ }
+
+  public DocMakerRamGen(boolean cacheResults) {
+    this.cacheResults = cacheResults;
+
+    Long seed = Long.getLong("threadLocalRandomSeed");
+    if (seed == null) {
+      System.setProperty("threadLocalRandomSeed", Long.toString(new 
Random().nextLong()));
+    }
+
+    threadRandom = new SplittableRandom(Long.getLong("threadLocalRandomSeed"));
+  }
+
+  public void preGenerateDocs(int numDocs) throws InterruptedException {
+    executorService = 
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
+    if (cacheResults) {
+      docs = CACHE.compute(Integer.toString(hashCode()), (key, value) -> {
+        if (value == null) {
+          for (int i = 0; i < numDocs; i++) {

Review comment:
       This is likely a fair bit to do on cleaning up / finalizing this 
docmaker - still pulling a bit from elsewhere to it and then I'll do some 
cleanup - next update.




-- 
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: issues-unsubscr...@solr.apache.org

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



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

Reply via email to