You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by at...@apache.org on 2025/04/17 18:28:29 UTC

(lucene) 10/18: Continued cleanups

This is an automated email from the ASF dual-hosted git repository.

atri pushed a commit to branch new_index_query_include
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 66ef86399fb28a93bbbef3a49eb1a07b38fbae04
Author: Atri Sharma <at...@192.168.1.75>
AuthorDate: Thu Apr 17 02:40:42 2025 +0530

    Continued cleanups
---
 .../benchmark/jmh/IndexingLatencyBenchmark.java    | 147 ---------------------
 .../org/apache/lucene/codecs/BinMapReader.java     |   2 -
 .../apache/lucene/search/BinBoostCalculator.java   |   1 -
 3 files changed, 150 deletions(-)

diff --git a/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/IndexingLatencyBenchmark.java b/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/IndexingLatencyBenchmark.java
deleted file mode 100644
index 3fe148e84e7..00000000000
--- a/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/IndexingLatencyBenchmark.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.lucene.benchmark.jmh;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Comparator;
-import java.util.concurrent.TimeUnit;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.codecs.lucene101.Lucene101Codec;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexOptions;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MMapDirectory;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Level;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Param;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.Setup;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.MILLISECONDS)
-@State(Scope.Thread)
-@Warmup(iterations = 2)
-@Measurement(iterations = 5)
-@Fork(1)
-public class IndexingLatencyBenchmark {
-
-  @Param({"true", "false"})
-  private String binningFlag;
-
-  @Param({"1000", "10000"})
-  private int docCount;
-
-  private boolean binningEnabled;
-  private FieldType fieldType;
-  private Path tempDir;
-
-  @Setup(Level.Trial)
-  public void setup() {
-    binningEnabled = Boolean.parseBoolean(binningFlag);
-    fieldType = new FieldType(TextField.TYPE_NOT_STORED);
-    fieldType.setTokenized(true);
-    fieldType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
-    if (binningEnabled) {
-      fieldType.putAttribute("postingsFormat", "Lucene101");
-      fieldType.putAttribute("doBinning", "true");
-      fieldType.putAttribute("bin.count", "4");
-    }
-    fieldType.freeze();
-  }
-
-  @Benchmark
-  public void indexBatch() throws IOException {
-    tempDir = Files.createTempDirectory("lucene-indexing-benchmark");
-    try (Directory dir = new MMapDirectory(tempDir)) {
-      IndexWriterConfig config = new IndexWriterConfig(new SingleTokenAnalyzer());
-      config.setCodec(new Lucene101Codec());
-      config.setUseCompoundFile(false);
-      try (IndexWriter writer = new IndexWriter(dir, config)) {
-        for (int i = 0; i < docCount; i++) {
-          Document doc = new Document();
-          String content = (i % 200 == 0) ? "lucene high quality text" : "noise filler token " + i;
-          doc.add(new Field("field", content, fieldType));
-          writer.addDocument(doc);
-        }
-        writer.commit();
-      }
-    } finally {
-      Files.walk(tempDir)
-          .sorted(Comparator.reverseOrder())
-          .forEach(
-              path -> {
-                try {
-                  Files.deleteIfExists(path);
-                } catch (IOException ignored) {
-                  // best-effort cleanup
-                }
-              });
-    }
-  }
-
-  /** Analyzer that emits a single token to avoid dependency on analyzer modules. */
-  private static final class SingleTokenAnalyzer extends Analyzer {
-    @Override
-    protected TokenStreamComponents createComponents(String fieldName) {
-      Tokenizer tokenizer =
-          new Tokenizer() {
-            private final CharTermAttribute attr = addAttribute(CharTermAttribute.class);
-            private boolean emitted = false;
-
-            @Override
-            public boolean incrementToken() {
-              if (emitted) {
-                return false;
-              }
-              clearAttributes();
-              attr.append("lucene");
-              emitted = true;
-              return true;
-            }
-
-            @Override
-            public void reset() throws IOException {
-              super.reset();
-              emitted = false;
-            }
-          };
-      return new TokenStreamComponents(tokenizer);
-    }
-
-    @Override
-    protected Reader initReader(String fieldName, Reader reader) {
-      return reader;
-    }
-  }
-}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BinMapReader.java b/lucene/core/src/java/org/apache/lucene/codecs/BinMapReader.java
index 908b391291f..4d39c8d43cf 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/BinMapReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/BinMapReader.java
@@ -12,13 +12,11 @@ package org.apache.lucene.codecs;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.util.Arrays;
 
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.SegmentReadState;
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.ArrayUtil;
 
 /**
  * Reads the binmap file for a segment and exposes per-document bin assignments.
diff --git a/lucene/core/src/java/org/apache/lucene/search/BinBoostCalculator.java b/lucene/core/src/java/org/apache/lucene/search/BinBoostCalculator.java
index 210438e8c42..da0657eedf2 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BinBoostCalculator.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BinBoostCalculator.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.search;
 
 import java.io.IOException;
-import java.util.Arrays;
 
 import org.apache.lucene.index.BinScoreLeafReader;
 import org.apache.lucene.index.BinScoreReader;