Apache Solr open-source search software
SOLR-18029: Implement bulk read when reading index properties (#3953)
Pierre Salagnacc9e2181e36e7
diff --git a/changelog/unreleased/SOLR-18029-properties-bulk-read.yml b/changelog/unreleased/SOLR-18029-properties-bulk-read.ymlnew file mode 100644index 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-18029diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex adaca2acd66..068b82285c0 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java@@ -173,8 +173,8 @@ 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.PropertiesInputStream;import org.apache.solr.util.RefCounted;import org.apache.solr.util.TestInjection;import org.apache.solr.util.circuitbreaker.CircuitBreaker;@@ -461,7 +461,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));@@ -1581,7 +1581,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.javaindex 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.javaindex 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.javaindex 888e371426a..cdc5de9313b 100644--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java@@ -111,8 +111,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.apache.solr.util.stats.MetricUtils;@@ -1196,7 +1196,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.javasimilarity index 70%rename from solr/core/src/java/org/apache/solr/util/PropertiesInputStream.javarename to solr/core/src/java/org/apache/solr/util/IndexInputInputStream.javaindex 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;+ }+@Overridepublic void close() throws IOException {super.close();