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

psalagnac pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 9aab8b62504 SOLR-18029: Implement bulk read when reading index 
properties (#3953)
9aab8b62504 is described below

commit 9aab8b62504705bfe4eb076e9aee30e2a16144a3
Author: Pierre Salagnac <[email protected]>
AuthorDate: Fri Dec 19 10:38:48 2025 +0100

    SOLR-18029: Implement bulk read when reading index properties (#3953)
    
    Implement bulk (array) read method to fill the internal buffer in a single 
call. Also rename class PropertiesInputStream into IndexInputInputStream to 
match the symmetrical IndexOutputOutputStream.
    
    (cherry picked from commit c9e2181e36e71123938e5bfbd9df55f1fc176992)
---
 .../unreleased/SOLR-18029-properties-bulk-read.yml |  8 ++++++++
 .../src/java/org/apache/solr/core/SolrCore.java    |  6 +++---
 .../apache/solr/core/backup/BackupProperties.java  |  4 ++--
 .../solr/core/backup/ShardBackupMetadata.java      |  4 ++--
 .../apache/solr/handler/ReplicationHandler.java    |  4 ++--
 ...InputStream.java => IndexInputInputStream.java} | 22 +++++++++++++++++++---
 6 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/changelog/unreleased/SOLR-18029-properties-bulk-read.yml 
b/changelog/unreleased/SOLR-18029-properties-bulk-read.yml
new file mode 100644
index 00000000000..62686475955
--- /dev/null
+++ b/changelog/unreleased/SOLR-18029-properties-bulk-read.yml
@@ -0,0 +1,8 @@
+title: PropertiesInputStream overrides bulk read method, and rename it to 
IndexInputInputStream to match
+       symmetrical class IndexOutputOutputStream.
+type: changed
+authors:
+  - name: Pierre Salagnac
+links:
+  - name: SOLR-18029
+    url: https://issues.apache.org/jira/browse/SOLR-18029
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java 
b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 1b0ef2e3f4f..3a5aab8411f 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -172,9 +172,9 @@ import 
org.apache.solr.update.processor.UpdateRequestProcessorChain;
 import 
org.apache.solr.update.processor.UpdateRequestProcessorChain.ProcessorInfo;
 import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
 import org.apache.solr.util.IOFunction;
+import org.apache.solr.util.IndexInputInputStream;
 import org.apache.solr.util.IndexOutputOutputStream;
 import org.apache.solr.util.NumberUtils;
-import org.apache.solr.util.PropertiesInputStream;
 import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.TestInjection;
 import org.apache.solr.util.circuitbreaker.CircuitBreaker;
@@ -457,7 +457,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
       return dataDir + "index/";
     }
     // c'tor just assigns a variable here, no exception thrown.
-    final InputStream is = new PropertiesInputStream(input);
+    final InputStream is = new IndexInputInputStream(input);
     try {
       Properties p = new Properties();
       p.load(new InputStreamReader(is, StandardCharsets.UTF_8));
@@ -1498,7 +1498,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
     try {
       final IndexInput input =
           dir.openInput(IndexFetcher.INDEX_PROPERTIES, 
DirectoryFactory.IOCONTEXT_NO_CACHE);
-      final InputStream is = new PropertiesInputStream(input);
+      final InputStream is = new IndexInputInputStream(input);
       try {
         p.load(new InputStreamReader(is, StandardCharsets.UTF_8));
       } catch (Exception e) {
diff --git 
a/solr/core/src/java/org/apache/solr/core/backup/BackupProperties.java 
b/solr/core/src/java/org/apache/solr/core/backup/BackupProperties.java
index dcc8509b574..4a7296a6f07 100644
--- a/solr/core/src/java/org/apache/solr/core/backup/BackupProperties.java
+++ b/solr/core/src/java/org/apache/solr/core/backup/BackupProperties.java
@@ -35,7 +35,7 @@ import org.apache.lucene.store.IOContext;
 import org.apache.lucene.util.Version;
 import org.apache.solr.common.params.CollectionAdminParams;
 import org.apache.solr.core.backup.repository.BackupRepository;
-import org.apache.solr.util.PropertiesInputStream;
+import org.apache.solr.util.IndexInputInputStream;
 
 /**
  * Represents a backup[-*].properties file, responsible for holding 
whole-collection and
@@ -104,7 +104,7 @@ public class BackupProperties {
     Properties props = new Properties();
     try (Reader is =
         new InputStreamReader(
-            new PropertiesInputStream(
+            new IndexInputInputStream(
                 repository.openInput(backupPath, fileName, IOContext.DEFAULT)),
             StandardCharsets.UTF_8)) {
       props.load(is);
diff --git 
a/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java 
b/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java
index c2fe588c068..7561e167fda 100644
--- a/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java
+++ b/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java
@@ -32,7 +32,7 @@ import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.backup.repository.BackupRepository;
-import org.apache.solr.util.PropertiesInputStream;
+import org.apache.solr.util.IndexInputInputStream;
 
 /**
  * Represents the shard-backup metadata file.
@@ -98,7 +98,7 @@ public class ShardBackupMetadata {
 
     try (IndexInput is =
         repository.openInput(dir, shardBackupMetadataFilename, 
IOContext.DEFAULT)) {
-      return from(new PropertiesInputStream(is));
+      return from(new IndexInputInputStream(is));
     }
   }
 
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java 
b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index a9988f49a7f..82ec30ae776 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -107,8 +107,8 @@ import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.security.AuthorizationContext;
 import org.apache.solr.update.SolrIndexWriter;
+import org.apache.solr.util.IndexInputInputStream;
 import org.apache.solr.util.NumberUtils;
-import org.apache.solr.util.PropertiesInputStream;
 import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.slf4j.Logger;
@@ -1192,7 +1192,7 @@ public class ReplicationHandler extends RequestHandlerBase
         }
 
         try {
-          final InputStream is = new PropertiesInputStream(input);
+          final InputStream is = new IndexInputInputStream(input);
           Properties props = new Properties();
           props.load(new InputStreamReader(is, StandardCharsets.UTF_8));
           return props;
diff --git a/solr/core/src/java/org/apache/solr/util/PropertiesInputStream.java 
b/solr/core/src/java/org/apache/solr/util/IndexInputInputStream.java
similarity index 70%
rename from solr/core/src/java/org/apache/solr/util/PropertiesInputStream.java
rename to solr/core/src/java/org/apache/solr/util/IndexInputInputStream.java
index 12a94529b20..3cb1831daa9 100644
--- a/solr/core/src/java/org/apache/solr/util/PropertiesInputStream.java
+++ b/solr/core/src/java/org/apache/solr/util/IndexInputInputStream.java
@@ -21,11 +21,11 @@ import java.io.IOException;
 import java.io.InputStream;
 import org.apache.lucene.store.IndexInput;
 
-public class PropertiesInputStream extends InputStream {
+public class IndexInputInputStream extends InputStream {
 
-  private IndexInput is;
+  private final IndexInput is;
 
-  public PropertiesInputStream(IndexInput is) {
+  public IndexInputInputStream(IndexInput is) {
     this.is = is;
   }
 
@@ -40,6 +40,22 @@ public class PropertiesInputStream extends InputStream {
     return next;
   }
 
+  @Override
+  public int read(byte[] b, int off, int len) throws IOException {
+    long pos = is.getFilePointer();
+    long length = is.length();
+    int remaining = Math.min(len, (int) (length - pos));
+
+    if (remaining == 0) {
+      return -1;
+    }
+
+    is.readBytes(b, off, remaining);
+
+    // We're sure always read as much as asked from the index
+    return remaining;
+  }
+
   @Override
   public void close() throws IOException {
     super.close();

Reply via email to