You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/21 17:51:03 UTC
[lucene-solr] branch reference_impl_dev updated: @598 Now I know I
can be happy as a clam, Because I'm beautiful, baby
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new 76f2ef6 @598 Now I know I can be happy as a clam, Because I'm beautiful, baby
76f2ef6 is described below
commit 76f2ef6c4fa710934b1cefed93780cfd922b3a7a
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Fri Aug 21 12:50:24 2020 -0500
@598 Now I know I can be happy as a clam, Because I'm beautiful, baby
---
.../client/solrj/embedded/JettySolrRunner.java | 148 ++++-----
.../src/java/org/apache/solr/cloud/Overseer.java | 25 +-
.../solr/cloud/autoscaling/AutoScalingHandler.java | 24 +-
.../apache/solr/cloud/overseer/ZkStateWriter.java | 6 +-
.../java/org/apache/solr/core/CoreContainer.java | 61 ++--
.../org/apache/solr/core/DirectoryFactory.java | 26 +-
.../java/org/apache/solr/core/RequestParams.java | 4 +-
.../src/java/org/apache/solr/core/SolrConfig.java | 2 +-
.../src/java/org/apache/solr/core/SolrCore.java | 10 +-
.../apache/solr/filestore/DistribPackageStore.java | 24 +-
.../solr/handler/AnalysisRequestHandlerBase.java | 107 ++++---
.../apache/solr/handler/ReplicationHandler.java | 4 +-
.../org/apache/solr/handler/SolrConfigHandler.java | 2 +-
.../org/apache/solr/handler/StreamHandler.java | 5 +-
.../solr/handler/admin/BaseHandlerApiSupport.java | 6 +-
.../solr/handler/admin/CollectionsHandler.java | 2 +-
.../solr/handler/component/HttpShardHandler.java | 6 +-
.../handler/component/RealTimeGetComponent.java | 5 +-
.../org/apache/solr/legacy/BBoxValueSource.java | 44 ++-
.../apache/solr/parser/SolrQueryParserBase.java | 31 +-
.../apache/solr/response/BinaryResponseWriter.java | 31 +-
.../src/java/org/apache/solr/rest/RestManager.java | 4 +-
.../org/apache/solr/schema/DateRangeField.java | 17 +-
.../src/java/org/apache/solr/schema/FieldType.java | 5 +-
.../java/org/apache/solr/schema/IndexSchema.java | 3 +-
.../org/apache/solr/schema/TrieDoubleField.java | 124 ++++----
.../org/apache/solr/schema/TrieFloatField.java | 123 ++++----
.../java/org/apache/solr/schema/TrieIntField.java | 124 ++++----
.../java/org/apache/solr/schema/TrieLongField.java | 122 ++++----
.../org/apache/solr/search/FieldQParserPlugin.java | 26 +-
.../src/java/org/apache/solr/search/Filter.java | 31 +-
.../src/java/org/apache/solr/search/Grouping.java | 9 +-
.../org/apache/solr/search/SolrIndexSearcher.java | 142 +++++----
.../org/apache/solr/search/ValueSourceParser.java | 329 +++++++++++++--------
.../org/apache/solr/search/facet/FacetModule.java | 2 +-
.../java/org/apache/solr/search/facet/SlotAcc.java | 34 ---
.../org/apache/solr/search/facet/StddevAgg.java | 6 +-
.../java/org/apache/solr/search/facet/SumAgg.java | 6 +-
.../org/apache/solr/search/facet/SumsqAgg.java | 4 +-
.../org/apache/solr/search/facet/VarianceAgg.java | 6 +-
.../solr/search/function/FileFloatSource.java | 33 ++-
.../solr/search/function/OrdFieldSource.java | 126 ++++----
.../grouping/distributed/command/QueryCommand.java | 3 +-
.../org/apache/solr/search/join/XCJFQuery.java | 2 +-
.../apache/solr/security/AuthenticationPlugin.java | 21 +-
.../java/org/apache/solr/servlet/HttpSolrCall.java | 9 +-
.../apache/solr/spelling/SpellCheckCollator.java | 5 +-
.../org/apache/solr/uninverting/DocTermOrds.java | 2 +-
.../org/apache/solr/update/TransactionLog.java | 2 +-
.../processor/DistributedUpdateProcessor.java | 5 -
.../DocExpirationUpdateProcessorFactory.java | 12 +-
.../org/apache/solr/util/ConcurrentLRUCache.java | 2 +-
.../java/org/apache/solr/util/DateMathParser.java | 2 +-
.../src/java/org/apache/solr/util/hll/BitUtil.java | 2 +-
.../src/java/org/apache/solr/util/hll/HLL.java | 2 +-
.../solr/handler/admin/TestCollectionAPIs.java | 16 +-
.../solr/client/solrj/impl/Http2SolrClient.java | 2 +-
.../src/java/org/apache/solr/common/ParWork.java | 17 +-
.../org/apache/solr/common/ParWorkExecutor.java | 2 +-
.../solr/common/util/SolrQueuedThreadPool.java | 2 +-
.../apache/solr/common/util/ValidatingJsonMap.java | 3 +-
.../apache/solr/client/solrj/SolrExampleTests.java | 4 +-
.../src/java/org/apache/solr/SolrTestCase.java | 10 -
63 files changed, 1095 insertions(+), 879 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
index 4ca76bd..c53c17e 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
@@ -29,13 +29,11 @@ import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.ObjectReleaseTracker;
import org.apache.solr.common.util.SolrQueuedThreadPool;
-import org.apache.solr.common.util.TimeSource;
import org.apache.solr.core.CloudConfig;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.NodeConfig;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.SolrQoSFilter;
-import org.apache.solr.util.TimeOut;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
@@ -108,7 +106,6 @@ public class JettySolrRunner implements Closeable {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static final int THREAD_POOL_MAX_THREADS = 10000;
// NOTE: should be larger than HttpClientUtil.DEFAULT_SO_TIMEOUT or typical client SO timeout
private static final int THREAD_POOL_MAX_IDLE_TIME_MS = HttpClientUtil.DEFAULT_SO_TIMEOUT + 30000;
@@ -147,7 +144,7 @@ public class JettySolrRunner implements Closeable {
private volatile boolean isClosed;
- private static Scheduler scheduler = new SolrHttpClientScheduler("JettySolrRunnerScheduler", true, null, new ThreadGroup("JettySolrRunnerScheduler"), 1);
+ private static final Scheduler scheduler = new SolrHttpClientScheduler("JettySolrRunnerScheduler", true, null, new ThreadGroup("JettySolrRunnerScheduler"), 3);
private volatile SolrQueuedThreadPool qtp;
private volatile boolean closed;
@@ -158,7 +155,7 @@ public class JettySolrRunner implements Closeable {
public static class DebugFilter implements Filter {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private AtomicLong nRequests = new AtomicLong();
+ private final AtomicLong nRequests = new AtomicLong();
private Set<Delay> delays = ConcurrentHashMap.newKeySet(50);
@@ -202,7 +199,7 @@ public class JettySolrRunner implements Closeable {
private void executeDelay() {
int delayMs = 0;
for (Delay delay: delays) {
- this.log.info("Delaying {}, for reason: {}", delay.delayValue, delay.reason);
+ log.info("Delaying {}, for reason: {}", delay.delayValue, delay.reason);
if (delay.counter.decrementAndGet() == 0) {
delayMs += delay.delayValue;
}
@@ -296,18 +293,12 @@ public class JettySolrRunner implements Closeable {
if (config.qtp != null) {
qtp = config.qtp;
} else {
+ // leave as match with prod setup
qtp = new SolrQueuedThreadPool("JettySolrRunner qtp");
- qtp.setMaxThreads(Integer.getInteger("solr.maxContainerThreads", THREAD_POOL_MAX_THREADS));
- qtp.setLowThreadsThreshold(Integer.getInteger("solr.lowContainerThreadsThreshold", -1)); // we don't use this or connections will get cut
- qtp.setMinThreads(Integer.getInteger("solr.minContainerThreads", 8));
- qtp.setIdleTimeout(Integer.getInteger("solr.containerThreadsIdle", THREAD_POOL_MAX_IDLE_TIME_MS));
- qtp.setStopTimeout(0);
- qtp.setReservedThreads(-1);
}
server = new Server(qtp);
-
server.setStopTimeout(60); // will wait gracefull for stoptime / 2, then interrupts
assert config.stopAtShutdown;
server.setStopAtShutdown(config.stopAtShutdown);
@@ -575,11 +566,9 @@ public class JettySolrRunner implements Closeable {
if (cloudConf != null) {
String localHostContext = ZkController.trimLeadingAndTrailingSlashes(cloudConf.getSolrHostContext());
- String zkServerAddress = cloudConf.getZkHost();
int localHostPort = cloudConf.getSolrHostPort();
String hostName = ZkController.normalizeHostName(cloudConf.getHost());
nodeName = ZkController.generateNodeName(hostName, Integer.toString(localHostPort), localHostContext);
-
}
}
@@ -601,32 +590,7 @@ public class JettySolrRunner implements Closeable {
SolrZkClient zkClient = getCoreContainer().getZkController().getZkStateReader().getZkClient();
CountDownLatch latch = new CountDownLatch(1);
- Watcher watcher = new Watcher() {
-
- @Override
- public void process(WatchedEvent event) {
- if (Event.EventType.None.equals(event.getType())) {
- return;
- } log.info("Got event on live node watcher {}", event.toString());
- if (event.getType() == Event.EventType.NodeCreated) {
- latch.countDown();
- } else {
- try {
- Stat stat = zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE, this);
- if (stat != null) {
- latch.countDown();
- }
- } catch (KeeperException e) {
- SolrException.log(log, e);
- return;
- } catch (InterruptedException e) {
- ParWork.propegateInterrupt(e);
- return;
- }
- }
-
- }
- };
+ Watcher watcher = new ClusterReadyWatcher(latch, zkClient);
try {
Stat stat = zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE, watcher);
if (stat == null) {
@@ -685,31 +649,6 @@ public class JettySolrRunner implements Closeable {
this.host = c.getHost();
}
- private void retryOnPortBindFailure(int portRetryTime, int port) throws Exception, InterruptedException {
- TimeOut timeout = new TimeOut(portRetryTime, TimeUnit.SECONDS, TimeSource.NANO_TIME);
- int tryCnt = 1;
- while (true) {
- try {
- log.info("Trying to start Jetty on port {} try number {} ...", port, tryCnt);
- tryCnt++;
- server.start();
- break;
- } catch (IOException ioe) {
- Exception e = lookForBindException(ioe);
- if (e instanceof BindException) {
- log.info("Port is in use, will try again until timeout of {}", timeout);
- server.stop();
- Thread.sleep(3000);
- if (!timeout.hasTimedOut()) {
- continue;
- }
- }
-
- throw e;
- }
- }
- }
-
/**
* Traverses the cause chain looking for a BindException. Returns either a bind exception
* that was found in the chain or the original argument.
@@ -766,42 +705,40 @@ public class JettySolrRunner implements Closeable {
ParWork.propegateInterrupt(e);
}
- } catch (Exception e) {
- SolrZkClient.checkInterrupted(e);
- log.error("", e);
- throw new RuntimeException(e);
- } finally {
-
- if (enableProxy) {
- proxy.close();
- }
if (wait && coreContainer != null && coreContainer
.isZooKeeperAware()) {
log.info("waitForJettyToStop: {}", getLocalPort());
String nodeName = getNodeName();
if (nodeName == null) {
log.info("Cannot wait for Jetty with null node name");
- return;
- }
+ } else {
- log.info("waitForNode: {}", getNodeName());
+ log.info("waitForNode: {}", getNodeName());
- ZkStateReader reader = coreContainer.getZkController()
- .getZkStateReader();
+ ZkStateReader reader = coreContainer.getZkController().getZkStateReader();
- try {
- if (!reader.isClosed() && reader.getZkClient().isConnected()) {
- reader.waitForLiveNodes(10, TimeUnit.SECONDS, (o, n) -> !n.contains(nodeName));
+ try {
+ if (!reader.isClosed() && reader.getZkClient().isConnected()) {
+ reader.waitForLiveNodes(10, TimeUnit.SECONDS, (o, n) -> !n.contains(nodeName));
+ }
+ } catch (InterruptedException e) {
+ ParWork.propegateInterrupt(e);
+ } catch (TimeoutException e) {
+ log.error("Timeout waiting for live node");
}
- } catch (InterruptedException e) {
- ParWork.propegateInterrupt(e);
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "interrupted", e);
- } catch (TimeoutException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
}
+ } catch (Exception e) {
+ SolrZkClient.checkInterrupted(e);
+ log.error("", e);
+ throw new RuntimeException(e);
+ } finally {
+
+ if (enableProxy) {
+ proxy.close();
+ }
+
assert ObjectReleaseTracker.release(this);
if (prevContext != null) {
MDC.setContextMap(prevContext);
@@ -979,7 +916,7 @@ public class JettySolrRunner implements Closeable {
return proxy;
}
- private final class NoopSessionManager implements SessionIdManager {
+ private static final class NoopSessionManager implements SessionIdManager {
@Override
public void stop() throws Exception {
}
@@ -1079,4 +1016,35 @@ public class JettySolrRunner implements Closeable {
}
}
+ private static class ClusterReadyWatcher implements Watcher {
+
+ private final CountDownLatch latch;
+ private final SolrZkClient zkClient;
+
+ public ClusterReadyWatcher(CountDownLatch latch, SolrZkClient zkClient) {
+ this.latch = latch;
+ this.zkClient = zkClient;
+ }
+
+ @Override
+ public void process(WatchedEvent event) {
+ if (Event.EventType.None.equals(event.getType())) {
+ return;
+ } log.info("Got event on live node watcher {}", event.toString());
+ if (event.getType() == Event.EventType.NodeCreated) {
+ latch.countDown();
+ } else {
+ try {
+ Stat stat = zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE, this);
+ if (stat != null) {
+ latch.countDown();
+ }
+ } catch (KeeperException e) {
+ SolrException.log(log, e);
+ } catch (InterruptedException e) {
+ ParWork.propegateInterrupt(e);
+ }
+ }
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
index e10695b..e1d6a56 100644
--- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java
+++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
@@ -166,6 +166,19 @@ public class Overseer implements SolrCloseable {
return closeAndDone;
}
+ private static class StringBiConsumer implements BiConsumer<String, Object> {
+ boolean firstPair = true;
+
+ @Override
+ public void accept(String s, Object o) {
+ if (firstPair) {
+ log.warn("WARNING: Collection '.system' may need re-indexing due to compatibility issues listed below. See REINDEXCOLLECTION documentation for more details.");
+ firstPair = false;
+ }
+ log.warn("WARNING: *\t{}:\t{}", s, o);
+ }
+ }
+
/**
* <p>This class is responsible for dequeueing state change requests from the ZooKeeper queue at <code>/overseer/queue</code>
* and executing the requested cluster change (essentially writing or updating <code>state.json</code> for a collection).</p>
@@ -678,17 +691,7 @@ public class Overseer implements SolrCloseable {
triggerThread.start();
}
- systemCollectionCompatCheck(new BiConsumer<String, Object>() {
- boolean firstPair = true;
- @Override
- public void accept(String s, Object o) {
- if (firstPair) {
- log.warn("WARNING: Collection '.system' may need re-indexing due to compatibility issues listed below. See REINDEXCOLLECTION documentation for more details.");
- firstPair = false;
- }
- log.warn("WARNING: *\t{}:\t{}", s, o);
- }
- });
+ systemCollectionCompatCheck(new StringBiConsumer());
assert ObjectReleaseTracker.track(this);
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
index 28522d4..c631835 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
@@ -139,14 +139,7 @@ public class AutoScalingHandler extends RequestHandlerBase implements Permission
AutoScalingConfig autoScalingConf = cloudManager.getDistribStateManager().getAutoScalingConfig();
if (parts.size() == 2) {
- autoScalingConf.writeMap(new MapWriter.EntryWriter() {
-
- @Override
- public MapWriter.EntryWriter put(CharSequence k, Object v) {
- rsp.getValues().add(k.toString(), v);
- return this;
- }
- });
+ autoScalingConf.writeMap(new MapEntryWriter(rsp));
} else {
getSubpathExecutor(parts, req).ifPresent(it -> it.accept(rsp, autoScalingConf));
}
@@ -748,4 +741,19 @@ public class AutoScalingHandler extends RequestHandlerBase implements Permission
if (path.equals("/diagnostics") || path.equals("/suggestions")) return this;
return null;
}
+
+ private static class MapEntryWriter implements MapWriter.EntryWriter {
+
+ private final SolrQueryResponse rsp;
+
+ public MapEntryWriter(SolrQueryResponse rsp) {
+ this.rsp = rsp;
+ }
+
+ @Override
+ public MapWriter.EntryWriter put(CharSequence k, Object v) {
+ rsp.getValues().add(k.toString(), v);
+ return this;
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
index ac60169..d46527a 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
@@ -260,8 +260,7 @@ public class ZkStateWriter {
}
ParWork.propegateInterrupt(e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Failed processing update=" + c + "\n" + prevState, e) {
- };
+ "Failed processing update=" + c + "\n" + prevState, e);
}
}
// }
@@ -383,8 +382,7 @@ public class ZkStateWriter {
// }
ParWork.propegateInterrupt(e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Failed processing update=" + c, e) {
- };
+ "Failed processing update=" + c, e);
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 481ff69..f0736c1 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -565,22 +565,10 @@ public class CoreContainer implements Closeable {
SolrHttpClientContextBuilder httpClientBuilder = new SolrHttpClientContextBuilder();
if (builder.getCredentialsProviderProvider() != null) {
- httpClientBuilder.setDefaultCredentialsProvider(new CredentialsProviderProvider() {
-
- @Override
- public CredentialsProvider getCredentialsProvider() {
- return builder.getCredentialsProviderProvider().getCredentialsProvider();
- }
- });
+ httpClientBuilder.setDefaultCredentialsProvider(new CredentialsProviderProvider(builder));
}
if (builder.getAuthSchemeRegistryProvider() != null) {
- httpClientBuilder.setAuthSchemeRegistryProvider(new AuthSchemeRegistryProvider() {
-
- @Override
- public Lookup<AuthSchemeProvider> getAuthSchemeRegistry() {
- return builder.getAuthSchemeRegistryProvider().getAuthSchemeRegistry();
- }
- });
+ httpClientBuilder.setAuthSchemeRegistryProvider(new AuthSchemeRegistryProvider(builder));
}
HttpClientUtil.setHttpClientRequestContextBuilder(httpClientBuilder);
@@ -989,12 +977,7 @@ public class CoreContainer implements Closeable {
name = "localhost";
}
cloudManager = null;
- client = new EmbeddedSolrServer(this, null) {
- @Override
- public void close() throws IOException {
- // do nothing - we close the container ourselves
- }
- };
+ client = new EmbeddedSolrServer();
// enable local metrics unless specifically set otherwise
if (!initArgs.containsKey(MetricsHistoryHandler.ENABLE_NODES_PROP)) {
initArgs.put(MetricsHistoryHandler.ENABLE_NODES_PROP, true);
@@ -2131,5 +2114,43 @@ public class CoreContainer implements Closeable {
ExecutorUtil.addThreadLocalProvider(SolrRequestInfo.getInheritableThreadLocalProvider());
}
+ private static class CredentialsProviderProvider extends SolrHttpClientContextBuilder.CredentialsProviderProvider {
+
+ private final SolrHttpClientBuilder builder;
+
+ public CredentialsProviderProvider(SolrHttpClientBuilder builder) {
+ this.builder = builder;
+ }
+
+ @Override
+ public CredentialsProvider getCredentialsProvider() {
+ return builder.getCredentialsProviderProvider().getCredentialsProvider();
+ }
+ }
+
+ private static class AuthSchemeRegistryProvider extends SolrHttpClientContextBuilder.AuthSchemeRegistryProvider {
+
+ private final SolrHttpClientBuilder builder;
+
+ public AuthSchemeRegistryProvider(SolrHttpClientBuilder builder) {
+ this.builder = builder;
+ }
+
+ @Override
+ public Lookup<AuthSchemeProvider> getAuthSchemeRegistry() {
+ return builder.getAuthSchemeRegistryProvider().getAuthSchemeRegistry();
+ }
+ }
+
+ private class EmbeddedSolrServer extends org.apache.solr.client.solrj.embedded.EmbeddedSolrServer {
+ public EmbeddedSolrServer() {
+ super(CoreContainer.this, null);
+ }
+
+ @Override
+ public void close() throws IOException {
+ // do nothing - we close the container ourselves
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
index 521397f..bc414f8 100644
--- a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
@@ -353,15 +353,7 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
}
final File currentIndexDir = new File(currentIndexDirPath);
- File[] oldIndexDirs = dataDir.listFiles(new FileFilter() {
- @Override
- public boolean accept(File file) {
- String fileName = file.getName();
- return file.isDirectory() &&
- !file.equals(currentIndexDir) &&
- (fileName.equals("index") || fileName.matches(INDEX_W_TIMESTAMP_REGEX));
- }
- });
+ File[] oldIndexDirs = dataDir.listFiles(new FileFilter(currentIndexDir));
if (oldIndexDirs == null || oldIndexDirs.length == 0)
return; // nothing to do (no log message needed)
@@ -433,4 +425,20 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
}
return dirFactory;
}
+
+ private static class FileFilter implements java.io.FileFilter {
+ private final File currentIndexDir;
+
+ public FileFilter(File currentIndexDir) {
+ this.currentIndexDir = currentIndexDir;
+ }
+
+ @Override
+ public boolean accept(File file) {
+ String fileName = file.getName();
+ return file.isDirectory() &&
+ !file.equals(currentIndexDir) &&
+ (fileName.equals("index") || fileName.matches(INDEX_W_TIMESTAMP_REGEX));
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/core/RequestParams.java b/solr/core/src/java/org/apache/solr/core/RequestParams.java
index 34ca17b..a16bee0 100644
--- a/solr/core/src/java/org/apache/solr/core/RequestParams.java
+++ b/solr/core/src/java/org/apache/solr/core/RequestParams.java
@@ -63,7 +63,7 @@ public class RequestParams implements MapSerializable {
Map.Entry e = (Map.Entry) o;
if (e.getValue() instanceof Map) {
Map value = (Map) e.getValue();
- this.paramsets.put((String) e.getKey(), createParamSet(value, 0l));
+ this.paramsets.put((String) e.getKey(), createParamSet(value, 0L));
}
}
}
@@ -240,7 +240,7 @@ public class RequestParams implements MapSerializable {
}
public Long getVersion() {
- return meta == null ? Long.valueOf(0l) : (Long) meta.get("v");
+ return meta == null ? Long.valueOf(0L) : (Long) meta.get("v");
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index 713c2ed..1ad4848 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -963,7 +963,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
} else {
if (plugin.options.contains(MULTI_OK)) {
ArrayList<MapSerializable> l = new ArrayList<>();
- for (PluginInfo info : infos) l.add(info);
+ l.addAll(infos);
result.put(tag, l);
} else {
result.put(tag, infos.get(0));
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 3b5b4f3..c82a95d 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1612,10 +1612,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
IOUtils.closeQuietly(reqHandlers);
return "reqHandlers";
});
- closeCalls.add(() -> {
- IOUtils.closeQuietly(responseWriters);
- return "responseWriters";
- });
+ closeCalls.add(this::call);
closeCalls.add(() -> {
IOUtils.closeQuietly(searchComponents);
return "searchComponents";
@@ -2841,6 +2838,11 @@ public final class SolrCore implements SolrInfoBean, Closeable {
return memClassLoader;
}
+ private Object call() {
+ IOUtils.closeQuietly(responseWriters);
+ return "responseWriters";
+ }
+
public interface RawWriter {
default String getContentType() {
return BinaryResponseParser.BINARY_CONTENT_TYPE;
diff --git a/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java b/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java
index be2e231..9ec83ce 100644
--- a/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java
+++ b/solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java
@@ -95,6 +95,21 @@ public class DistribPackageStore implements PackageStore {
File.separator + PackageStoreAPI.PACKAGESTORE_DIRECTORY + path).toPath();
}
+ private static class SolrFileEntry extends PackageStore.FileEntry {
+ private final InputStream is;
+
+ public SolrFileEntry(String path, InputStream is) {
+ super(null, null, path);
+ this.is = is;
+ }
+
+ //no metadata for metadata file
+ @Override
+ public InputStream getInputStream() {
+ return is;
+ }
+ }
+
class FileInfo {
final String path;
String metaPath;
@@ -259,7 +274,6 @@ public class DistribPackageStore implements PackageStore {
}
-
public FileDetails getDetails() {
FileType type = getType(path, false);
@@ -432,13 +446,7 @@ public class DistribPackageStore implements PackageStore {
String simpleName = file.getName();
if (isMetaDataFile(simpleName)) {
try (InputStream is = new FileInputStream(file)) {
- consumer.accept(new FileEntry(null, null, path) {
- //no metadata for metadata file
- @Override
- public InputStream getInputStream() {
- return is;
- }
- });
+ consumer.accept(new SolrFileEntry(path, is));
}
return;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
index 8dbbdc1..f9dc10a 100644
--- a/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
@@ -67,6 +67,7 @@ import org.apache.solr.schema.FieldType;
public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
public static final Set<BytesRef> EMPTY_BYTES_SET = Collections.emptySet();
+ public static final AttributeSource[] TS = new AttributeSource[0];
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
@@ -237,30 +238,10 @@ public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
private List<NamedList> convertTokensToNamedLists(final List<AttributeSource> tokenList, AnalysisContext context) {
final List<NamedList> tokensNamedLists = new ArrayList<>();
final FieldType fieldType = context.getFieldType();
- final AttributeSource[] tokens = tokenList.toArray(new AttributeSource[tokenList.size()]);
+ final AttributeSource[] tokens = tokenList.toArray(TS);
// sort the tokens by absolute position
- ArrayUtil.timSort(tokens, new Comparator<AttributeSource>() {
- @Override
- public int compare(AttributeSource a, AttributeSource b) {
- return arrayCompare(
- a.getAttribute(TokenTrackingAttribute.class).getPositions(),
- b.getAttribute(TokenTrackingAttribute.class).getPositions()
- );
- }
-
- private int arrayCompare(int[] a, int[] b) {
- int p = 0;
- final int stop = Math.min(a.length, b.length);
- while(p < stop) {
- int diff = a[p] - b[p];
- if (diff != 0) return diff;
- p++;
- }
- // One is a prefix of the other, or, they are equal:
- return a.length - b.length;
- }
- });
+ ArrayUtil.timSort(tokens, new AttributeSourceComparator());
for (int i = 0; i < tokens.length; i++) {
AttributeSource token = tokens[i];
@@ -289,32 +270,7 @@ public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
tokenNamedList.add("match", true);
}
- token.reflectWith(new AttributeReflector() {
- @Override
- public void reflect(Class<? extends Attribute> attClass, String key, Object value) {
- // leave out position and bytes term
- if (TermToBytesRefAttribute.class.isAssignableFrom(attClass))
- return;
- if (CharTermAttribute.class.isAssignableFrom(attClass))
- return;
- if (PositionIncrementAttribute.class.isAssignableFrom(attClass))
- return;
-
- String k = attClass.getName() + '#' + key;
-
- // map keys for "standard attributes":
- if (ATTRIBUTE_MAPPING.containsKey(k)) {
- k = ATTRIBUTE_MAPPING.get(k);
- }
-
- if (value instanceof BytesRef) {
- final BytesRef p = (BytesRef) value;
- value = p.toString();
- }
-
- tokenNamedList.add(k, value);
- }
- });
+ token.reflectWith(new SolrAttributeReflector(tokenNamedList));
tokensNamedLists.add(tokenNamedList);
}
@@ -537,4 +493,59 @@ public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
return termsToMatch;
}
}
+
+ private static class AttributeSourceComparator implements Comparator<AttributeSource> {
+ @Override
+ public int compare(AttributeSource a, AttributeSource b) {
+ return arrayCompare(
+ a.getAttribute(TokenTrackingAttribute.class).getPositions(),
+ b.getAttribute(TokenTrackingAttribute.class).getPositions()
+ );
+ }
+
+ private int arrayCompare(int[] a, int[] b) {
+ int p = 0;
+ final int stop = Math.min(a.length, b.length);
+ while(p < stop) {
+ int diff = a[p] - b[p];
+ if (diff != 0) return diff;
+ p++;
+ }
+ // One is a prefix of the other, or, they are equal:
+ return a.length - b.length;
+ }
+ }
+
+ private static class SolrAttributeReflector implements AttributeReflector {
+ private final NamedList<Object> tokenNamedList;
+
+ public SolrAttributeReflector(NamedList<Object> tokenNamedList) {
+ this.tokenNamedList = tokenNamedList;
+ }
+
+ @Override
+ public void reflect(Class<? extends Attribute> attClass, String key, Object value) {
+ // leave out position and bytes term
+ if (TermToBytesRefAttribute.class.isAssignableFrom(attClass))
+ return;
+ if (CharTermAttribute.class.isAssignableFrom(attClass))
+ return;
+ if (PositionIncrementAttribute.class.isAssignableFrom(attClass))
+ return;
+
+ String k = attClass.getName() + '#' + key;
+
+ // map keys for "standard attributes":
+ if (ATTRIBUTE_MAPPING.containsKey(k)) {
+ k = ATTRIBUTE_MAPPING.get(k);
+ }
+
+ if (value instanceof BytesRef) {
+ final BytesRef p = (BytesRef) value;
+ value = p.toString();
+ }
+
+ tokenNamedList.add(k, value);
+ }
+ }
}
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 65c562d..65c72a8 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -1064,7 +1064,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
currFileSizeDownloaded = (Long) currentFile.get("bytesDownloaded");
bytesDownloaded += currFileSizeDownloaded;
if (currFileSize > 0)
- percentDownloaded = (currFileSizeDownloaded * 100) / currFileSize;
+ percentDownloaded = (currFileSizeDownloaded * 100) / (float) currFileSize;
}
}
slave.add("filesDownloaded", filesDownloaded);
@@ -1084,7 +1084,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
float totalPercent = 0;
long downloadSpeed = 0;
if (bytesToDownload > 0)
- totalPercent = (bytesDownloaded * 100) / bytesToDownload;
+ totalPercent = (bytesDownloaded * 100) / (float) bytesToDownload;
if (elapsed > 0)
downloadSpeed = (bytesDownloaded / elapsed);
if (currFile != null)
diff --git a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
index f420f5f..1e163f2 100644
--- a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
@@ -157,7 +157,7 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
}
- private class Command {
+ private static class Command {
private final SolrQueryRequest req;
private final SolrQueryResponse resp;
private final String method;
diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
index 98d0689..08028bc 100644
--- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
@@ -19,6 +19,7 @@ package org.apache.solr.handler;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -510,9 +511,7 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,
String[] shards = shardString.split(",");
@SuppressWarnings({"rawtypes"})
List<String> shardList = new ArrayList<>();
- for (String shard : shards) {
- shardList.add(shard);
- }
+ shardList.addAll(Arrays.asList(shards));
collectionShards.put(collection, shardList);
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java b/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
index f4c4d95..282e791 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
@@ -50,6 +50,8 @@ import static org.apache.solr.common.util.StrUtils.splitSmart;
* to actions and old parameter names to new parameter names
*/
public abstract class BaseHandlerApiSupport implements ApiSupport {
+ public static final Object[] TS = new Object[0];
+ public static final String[] TS1 = new String[0];
protected final Map<SolrRequest.METHOD, Map<V2EndPoint, List<ApiCommand>>> commandsMapping;
protected BaseHandlerApiSupport() {
@@ -163,7 +165,7 @@ public abstract class BaseHandlerApiSupport implements ApiSupport {
if (o instanceof List) {
@SuppressWarnings({"rawtypes"})
List l = (List) o;
- return l.toArray(new String[l.size()]);
+ return l.toArray(TS);
}
return o;
@@ -203,7 +205,7 @@ public abstract class BaseHandlerApiSupport implements ApiSupport {
} else if (List.class.isAssignableFrom(oClass) && ((List)o).get(0) instanceof String ) {
@SuppressWarnings({"unchecked"})
List<String> l = (List<String>) o;
- suppliedMap.put( param, l.toArray(new String[0]));
+ suppliedMap.put( param, l.toArray(TS1));
} else {
// Lists pass through but will require special handling downstream
// if they contain non-string elements.
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index 0f02e38..9ed9158 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -689,7 +689,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
}
// Now filter out just the parameters we care about from the request
- assert routedAlias != null;
+ // assert routedAlias != null;
Map<String, Object> result = copy(finalParams, null, routedAlias.getRequiredParams());
copy(finalParams, result, routedAlias.getOptionalParams());
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index 23f71d8..2896950 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -69,6 +69,8 @@ import org.slf4j.MDC;
public class HttpShardHandler extends ShardHandler {
+ public static final String[] TS = new String[0];
+ public static final String[] TS1 = new String[0];
/**
* If the request context map has an entry with this key and Boolean.TRUE as value,
* {@link #prepDistributed(ResponseBuilder)} will only include {@link org.apache.solr.common.cloud.Replica.Type#NRT} replicas as possible
@@ -451,7 +453,7 @@ public class HttpShardHandler extends ShardHandler {
if (shards != null) {
List<String> lst = StrUtils.splitSmart(shards, ",", true);
- rb.shards = lst.toArray(new String[lst.size()]);
+ rb.shards = lst.toArray(TS);
rb.slices = new String[rb.shards.length];
if (zkController != null) {
@@ -502,7 +504,7 @@ public class HttpShardHandler extends ShardHandler {
// Store the logical slices in the ResponseBuilder and create a new
// String array to hold the physical shards (which will be mapped
// later).
- rb.slices = slices.keySet().toArray(new String[slices.size()]);
+ rb.slices = slices.keySet().toArray(TS1);
rb.shards = new String[rb.slices.length];
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index 7882121..8af6a09 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -19,6 +19,7 @@ package org.apache.solr.handler.component;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -1327,9 +1328,7 @@ public class RealTimeGetComponent extends SearchComponent
final List<String> allIds = new ArrayList<>((null == id ? 0 : id.length)
+ (null == ids ? 0 : (2 * ids.length)));
if (null != id) {
- for (String singleId : id) {
- allIds.add(singleId);
- }
+ allIds.addAll(Arrays.asList(id));
}
if (null != ids) {
for (String idList : ids) {
diff --git a/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java b/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
index 516f207..57ca10f 100644
--- a/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
+++ b/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
@@ -57,20 +57,7 @@ class BBoxValueSource extends ShapeValuesSource {
//reused
final Rectangle rect = strategy.getSpatialContext().makeRectangle(0,0,0,0);
- return new ShapeValues() {
-
- @Override
- public boolean advanceExact(int doc) throws IOException {
- return minX.advanceExact(doc) && maxX.advanceExact(doc) && minY.advanceExact(doc) && maxY.advanceExact(doc);
- }
-
- @Override
- public Shape value() throws IOException {
- rect.reset(minX.doubleValue(), maxX.doubleValue(), minY.doubleValue(), maxY.doubleValue());
- return rect;
- }
-
- };
+ return new ShapeValues(minX, maxX, minY, maxY, rect);
}
@Override
@@ -95,4 +82,33 @@ class BBoxValueSource extends ShapeValuesSource {
public int hashCode() {
return strategy.hashCode();
}
+
+ private static class ShapeValues extends org.apache.lucene.spatial.ShapeValues {
+
+ private final DoubleValues minX;
+ private final DoubleValues maxX;
+ private final DoubleValues minY;
+ private final DoubleValues maxY;
+ private final Rectangle rect;
+
+ public ShapeValues(DoubleValues minX, DoubleValues maxX, DoubleValues minY, DoubleValues maxY, Rectangle rect) {
+ this.minX = minX;
+ this.maxX = maxX;
+ this.minY = minY;
+ this.maxY = maxY;
+ this.rect = rect;
+ }
+
+ @Override
+ public boolean advanceExact(int doc) throws IOException {
+ return minX.advanceExact(doc) && maxX.advanceExact(doc) && minY.advanceExact(doc) && maxY.advanceExact(doc);
+ }
+
+ @Override
+ public Shape value() throws IOException {
+ rect.reset(minX.doubleValue(), maxX.doubleValue(), minY.doubleValue(), maxY.doubleValue());
+ return rect;
+ }
+
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
index a4084d1..b014f8a 100644
--- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
+++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
@@ -1244,19 +1244,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
// subtract these away
automaton = Operations.minus(automaton, falsePositives, Operations.DEFAULT_MAX_DETERMINIZED_STATES);
}
- return new AutomatonQuery(term, automaton) {
- // override toString so it's completely transparent
- @Override
- public String toString(String field) {
- StringBuilder buffer = new StringBuilder();
- if (!getField().equals(field)) {
- buffer.append(getField());
- buffer.append(":");
- }
- buffer.append(term.text());
- return buffer.toString();
- }
- };
+ return new AutomatonQuery(term, automaton);
}
// Solr has always used constant scoring for wildcard queries. This should return constant scoring by default.
@@ -1291,4 +1279,21 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
return new FilterQuery(q);
}
+ private static class AutomatonQuery extends org.apache.lucene.search.AutomatonQuery {
+ public AutomatonQuery(Term term, Automaton automaton) {
+ super(term, automaton);
+ }
+
+ // override toString so it's completely transparent
+ @Override
+ public String toString(String field) {
+ StringBuilder buffer = new StringBuilder();
+ if (!getField().equals(field)) {
+ buffer.append(getField());
+ buffer.append(":");
+ }
+ buffer.append(term.text());
+ return buffer.toString();
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java b/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
index 617f92c..7650ac5 100644
--- a/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.function.Consumer;
import org.apache.commons.io.output.ByteArrayOutputStream;
@@ -259,17 +260,7 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
@Override
public Iterator<Entry<String, Object>> iterator() {
Iterator<Entry<String, Object>> it = _fields.entrySet().iterator();
- return new Iterator<Entry<String, Object>>() {
- @Override
- public boolean hasNext() {
- return it.hasNext();
- }
-
- @Override
- public Entry<String, Object> next() {
- return convertCharSeq(it.next());
- }
- };
+ return new EntryIterator(it);
}
@@ -304,6 +295,24 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
public void forEach(Consumer<? super Entry<String, Object>> action) {
super.forEach(action);
}
+
+ private static class EntryIterator implements Iterator<Entry<String, Object>> {
+ private final Iterator<Entry<String,Object>> it;
+
+ public EntryIterator(Iterator<Entry<String,Object>> it) {
+ this.it = it;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public Entry<String, Object> next() {
+ return convertCharSeq(it.next());
+ }
+ }
}
}
diff --git a/solr/core/src/java/org/apache/solr/rest/RestManager.java b/solr/core/src/java/org/apache/solr/rest/RestManager.java
index addee77..8f5aa1b 100644
--- a/solr/core/src/java/org/apache/solr/rest/RestManager.java
+++ b/solr/core/src/java/org/apache/solr/rest/RestManager.java
@@ -123,9 +123,7 @@ public class RestManager {
public Registry() {
reservedEndpoints.add(SCHEMA_BASE_PATH + MANAGED_ENDPOINT);
- for (String reservedEndpoint : SolrSchemaRestApi.getReservedEndpoints()) {
- reservedEndpoints.add(reservedEndpoint);
- }
+ reservedEndpoints.addAll(SolrSchemaRestApi.getReservedEndpoints());
reservedEndpointsPattern = getReservedEndpointsPattern();
}
diff --git a/solr/core/src/java/org/apache/solr/schema/DateRangeField.java b/solr/core/src/java/org/apache/solr/schema/DateRangeField.java
index 67aa9fd..7c74ca5 100644
--- a/solr/core/src/java/org/apache/solr/schema/DateRangeField.java
+++ b/solr/core/src/java/org/apache/solr/schema/DateRangeField.java
@@ -146,12 +146,7 @@ public class DateRangeField extends AbstractSpatialPrefixTreeFieldType<NumberRan
protected Query getSpecializedRangeQuery(QParser parser, SchemaField field, String startStr, String endStr, boolean minInclusive, boolean maxInclusive) {
if (parser == null) {//null when invoked by SimpleFacets. But getQueryFromSpatialArgs expects to get localParams.
final SolrRequestInfo requestInfo = SolrRequestInfo.getRequestInfo();
- parser = new QParser("", null, requestInfo.getReq().getParams(), requestInfo.getReq()) {
- @Override
- public Query parse() throws SyntaxError {
- throw new IllegalStateException();
- }
- };
+ parser = new QSolrParser(requestInfo);
}
Calendar startCal;
@@ -177,4 +172,14 @@ public class DateRangeField extends AbstractSpatialPrefixTreeFieldType<NumberRan
return getQueryFromSpatialArgs(parser, field, spatialArgs);
}
+ private static class QSolrParser extends org.apache.solr.search.QParser {
+ public QSolrParser(SolrRequestInfo requestInfo) {
+ super("", null, requestInfo.getReq().getParams(), requestInfo.getReq());
+ }
+
+ @Override
+ public Query parse() throws SyntaxError {
+ throw new IllegalStateException();
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/schema/FieldType.java b/solr/core/src/java/org/apache/solr/schema/FieldType.java
index ee6dfdb..656ee75 100644
--- a/solr/core/src/java/org/apache/solr/schema/FieldType.java
+++ b/solr/core/src/java/org/apache/solr/schema/FieldType.java
@@ -19,6 +19,7 @@ package org.apache.solr.schema;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -1119,9 +1120,7 @@ public abstract class FieldType extends FieldProperties {
}
} else { // Don't show defaults
Set<String> fieldProperties = new HashSet<>();
- for (String propertyName : FieldProperties.propertyNames) {
- fieldProperties.add(propertyName);
- }
+ fieldProperties.addAll(Arrays.asList(FieldProperties.propertyNames));
for (Map.Entry<String, String> entry : args.entrySet()) {
String key = entry.getKey();
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 9505af9..2d3d9d2 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -138,6 +138,7 @@ public class IndexSchema {
private static final String SOURCE_EXPLICIT_FIELDS = "sourceExplicitFields";
private static final String TEXT_FUNCTION = "text()";
private static final String XPATH_OR = " | ";
+ public static final DynamicField[] TS = new DynamicField[0];
private static XPathExpression xpathOrExp;
private static XPathExpression schemaNameExp;
@@ -829,7 +830,7 @@ public class IndexSchema {
// Avoid creating the array twice by converting to an array first and using Arrays.sort(),
// rather than Collections.sort() then converting to an array, since Collections.sort()
// copies to an array first, then sets each collection member from the array.
- DynamicField[] dFields = dynamicFieldList.toArray(new DynamicField[dynamicFieldList.size()]);
+ DynamicField[] dFields = dynamicFieldList.toArray(TS);
Arrays.sort(dFields);
if (log.isTraceEnabled()) {
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java b/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
index 8e622c6..773ca2a 100644
--- a/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
@@ -68,69 +68,83 @@ public class TrieDoubleField extends TrieField implements DoubleValueFieldType {
@Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {
- return new SortedSetFieldSource(f.getName(), choice) {
+ return new SortedSetFieldSource(f, choice);
+ }
+
+ private static class SortedSetFieldSource extends org.apache.lucene.queries.function.valuesource.SortedSetFieldSource {
+ public SortedSetFieldSource(SchemaField f, SortedSetSelector.Type choice) {
+ super(f.getName(), choice);
+ }
+
+ @Override
+ public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
+ org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
+
+ SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
+ SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
+
+ return new DoubleDocValues(thisAsSortedSetFieldSource, view);
+ }
+
+ private static class DoubleDocValues extends org.apache.lucene.queries.function.docvalues.DoubleDocValues {
+ private final SortedDocValues view;
+ private int lastDocID;
+
+ public DoubleDocValues(org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource, SortedDocValues view) {
+ super(thisAsSortedSetFieldSource);
+ this.view = view;
+ }
+
+ private boolean setDoc(int docID) throws IOException {
+ if (docID < lastDocID) {
+ throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
+ }
+ if (docID > view.docID()) {
+ lastDocID = docID;
+ return docID == view.advance(docID);
+ } else {
+ return docID == view.docID();
+ }
+ }
+
@Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
-
- SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
- SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
-
- return new DoubleDocValues(thisAsSortedSetFieldSource) {
- private int lastDocID;
-
- private boolean setDoc(int docID) throws IOException {
- if (docID < lastDocID) {
- throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
- }
- if (docID > view.docID()) {
- lastDocID = docID;
- return docID == view.advance(docID);
- } else {
- return docID == view.docID();
- }
- }
-
- @Override
- public double doubleVal(int doc) throws IOException {
- if (setDoc(doc)) {
- BytesRef bytes = view.binaryValue();
- assert bytes.length > 0;
- return NumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(bytes));
- } else {
- return 0D;
- }
- }
+ public double doubleVal(int doc) throws IOException {
+ if (setDoc(doc)) {
+ BytesRef bytes = view.binaryValue();
+ assert bytes.length > 0;
+ return NumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(bytes));
+ } else {
+ return 0D;
+ }
+ }
+
+ @Override
+ public boolean exists(int doc) throws IOException {
+ return setDoc(doc);
+ }
+
+ @Override
+ public ValueFiller getValueFiller() {
+ return new ValueFiller() {
+ private final MutableValueDouble mval = new MutableValueDouble();
@Override
- public boolean exists(int doc) throws IOException {
- return setDoc(doc);
+ public MutableValue getValue() {
+ return mval;
}
@Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueDouble mval = new MutableValueDouble();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- if (setDoc(doc)) {
- mval.exists = true;
- mval.value = NumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(view.binaryValue()));
- } else {
- mval.exists = false;
- mval.value = 0D;
- }
- }
- };
+ public void fillValue(int doc) throws IOException {
+ if (setDoc(doc)) {
+ mval.exists = true;
+ mval.value = NumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(view.binaryValue()));
+ } else {
+ mval.exists = false;
+ mval.value = 0D;
+ }
}
};
}
- };
+ }
}
}
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java b/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
index b789564..4152a4e 100644
--- a/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
@@ -68,69 +68,82 @@ public class TrieFloatField extends TrieField implements FloatValueFieldType {
@Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {
- return new SortedSetFieldSource(f.getName(), choice) {
+ return new SortedSetFieldSource(f, choice);
+ }
+
+ private static class SortedSetFieldSource extends org.apache.lucene.queries.function.valuesource.SortedSetFieldSource {
+ public SortedSetFieldSource(SchemaField f, SortedSetSelector.Type choice) {
+ super(f.getName(), choice);
+ }
+
+ @Override
+ public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
+ org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
+
+ SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
+ SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
+
+ return new FloatDocValues(thisAsSortedSetFieldSource, view);
+ }
+
+ private static class FloatDocValues extends org.apache.lucene.queries.function.docvalues.FloatDocValues {
+ private final SortedDocValues view;
+ private int lastDocID;
+
+ public FloatDocValues(org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource, SortedDocValues view) {
+ super(thisAsSortedSetFieldSource);
+ this.view = view;
+ }
+
+ private boolean setDoc(int docID) throws IOException {
+ if (docID < lastDocID) {
+ throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
+ }
+ if (docID > view.docID()) {
+ return docID == view.advance(docID);
+ } else {
+ return docID == view.docID();
+ }
+ }
+
@Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
-
- SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
- SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
-
- return new FloatDocValues(thisAsSortedSetFieldSource) {
- private int lastDocID;
-
- private boolean setDoc(int docID) throws IOException {
- if (docID < lastDocID) {
- throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
- }
- if (docID > view.docID()) {
- return docID == view.advance(docID);
- } else {
- return docID == view.docID();
- }
- }
-
- @Override
- public float floatVal(int doc) throws IOException {
- if (setDoc(doc)) {
- BytesRef bytes = view.binaryValue();
- assert bytes.length > 0;
- return NumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(bytes));
- } else {
- return 0F;
- }
- }
+ public float floatVal(int doc) throws IOException {
+ if (setDoc(doc)) {
+ BytesRef bytes = view.binaryValue();
+ assert bytes.length > 0;
+ return NumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(bytes));
+ } else {
+ return 0F;
+ }
+ }
+
+ @Override
+ public boolean exists(int doc) throws IOException {
+ return setDoc(doc);
+ }
+
+ @Override
+ public ValueFiller getValueFiller() {
+ return new ValueFiller() {
+ private final MutableValueFloat mval = new MutableValueFloat();
@Override
- public boolean exists(int doc) throws IOException {
- return setDoc(doc);
+ public MutableValue getValue() {
+ return mval;
}
@Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueFloat mval = new MutableValueFloat();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- if (setDoc(doc)) {
- mval.exists = true;
- mval.value = NumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(view.binaryValue()));
- } else {
- mval.exists = false;
- mval.value = 0F;
- }
- }
- };
+ public void fillValue(int doc) throws IOException {
+ if (setDoc(doc)) {
+ mval.exists = true;
+ mval.value = NumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(view.binaryValue()));
+ } else {
+ mval.exists = false;
+ mval.value = 0F;
+ }
}
};
}
- };
+ }
}
-
}
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieIntField.java b/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
index 8acb66d..e943ced 100644
--- a/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
@@ -66,69 +66,83 @@ public class TrieIntField extends TrieField implements IntValueFieldType {
@Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {
- return new SortedSetFieldSource(f.getName(), choice) {
+ return new SortedSetFieldSource(f, choice);
+ }
+
+ private static class SortedSetFieldSource extends org.apache.lucene.queries.function.valuesource.SortedSetFieldSource {
+ public SortedSetFieldSource(SchemaField f, SortedSetSelector.Type choice) {
+ super(f.getName(), choice);
+ }
+
+ @Override
+ public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
+ org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
+
+ SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
+ SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
+
+ return new IntDocValues(thisAsSortedSetFieldSource, view);
+ }
+
+ private static class IntDocValues extends org.apache.lucene.queries.function.docvalues.IntDocValues {
+ private final SortedDocValues view;
+ private int lastDocID;
+
+ public IntDocValues(org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource, SortedDocValues view) {
+ super(thisAsSortedSetFieldSource);
+ this.view = view;
+ }
+
+ private boolean setDoc(int docID) throws IOException {
+ if (docID < lastDocID) {
+ throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
+ }
+ if (docID > view.docID()) {
+ lastDocID = docID;
+ return docID == view.advance(docID);
+ } else {
+ return docID == view.docID();
+ }
+ }
+
@Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
-
- SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
- SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
-
- return new IntDocValues(thisAsSortedSetFieldSource) {
- private int lastDocID;
-
- private boolean setDoc(int docID) throws IOException {
- if (docID < lastDocID) {
- throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
- }
- if (docID > view.docID()) {
- lastDocID = docID;
- return docID == view.advance(docID);
- } else {
- return docID == view.docID();
- }
- }
-
- @Override
- public int intVal(int doc) throws IOException {
- if (setDoc(doc)) {
- BytesRef bytes = view.binaryValue();
- assert bytes.length > 0;
- return LegacyNumericUtils.prefixCodedToInt(bytes);
- } else {
- return 0;
- }
- }
+ public int intVal(int doc) throws IOException {
+ if (setDoc(doc)) {
+ BytesRef bytes = view.binaryValue();
+ assert bytes.length > 0;
+ return LegacyNumericUtils.prefixCodedToInt(bytes);
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public boolean exists(int doc) throws IOException {
+ return setDoc(doc);
+ }
+
+ @Override
+ public ValueFiller getValueFiller() {
+ return new ValueFiller() {
+ private final MutableValueInt mval = new MutableValueInt();
@Override
- public boolean exists(int doc) throws IOException {
- return setDoc(doc);
+ public MutableValue getValue() {
+ return mval;
}
@Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueInt mval = new MutableValueInt();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- if (setDoc(doc)) {
- mval.exists = true;
- mval.value = LegacyNumericUtils.prefixCodedToInt(view.binaryValue());
- } else {
- mval.exists = false;
- mval.value = 0;
- }
- }
- };
+ public void fillValue(int doc) throws IOException {
+ if (setDoc(doc)) {
+ mval.exists = true;
+ mval.value = LegacyNumericUtils.prefixCodedToInt(view.binaryValue());
+ } else {
+ mval.exists = false;
+ mval.value = 0;
+ }
}
};
}
- };
+ }
}
}
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieLongField.java b/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
index bf6d393..03aa2ea 100644
--- a/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
@@ -66,69 +66,83 @@ public class TrieLongField extends TrieField implements LongValueFieldType {
@Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {
- return new SortedSetFieldSource(f.getName(), choice) {
+ return new SortedSetFieldSource(f, choice);
+ }
+
+ private static class SortedSetFieldSource extends org.apache.lucene.queries.function.valuesource.SortedSetFieldSource {
+ public SortedSetFieldSource(SchemaField f, SortedSetSelector.Type choice) {
+ super(f.getName(), choice);
+ }
+
+ @Override
+ public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
+ org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
+
+ SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
+ SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
+
+ return new LongDocValues(thisAsSortedSetFieldSource, view);
+ }
+
+ private static class LongDocValues extends org.apache.lucene.queries.function.docvalues.LongDocValues {
+ private final SortedDocValues view;
+ private int lastDocID;
+
+ public LongDocValues(org.apache.lucene.queries.function.valuesource.SortedSetFieldSource thisAsSortedSetFieldSource, SortedDocValues view) {
+ super(thisAsSortedSetFieldSource);
+ this.view = view;
+ }
+
+ private boolean setDoc(int docID) throws IOException {
+ if (docID < lastDocID) {
+ throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
+ }
+ if (docID > view.docID()) {
+ lastDocID = docID;
+ return docID == view.advance(docID);
+ } else {
+ return docID == view.docID();
+ }
+ }
+
@Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- SortedSetFieldSource thisAsSortedSetFieldSource = this; // needed for nested anon class ref
-
- SortedSetDocValues sortedSet = DocValues.getSortedSet(readerContext.reader(), field);
- SortedDocValues view = SortedSetSelector.wrap(sortedSet, selector);
-
- return new LongDocValues(thisAsSortedSetFieldSource) {
- private int lastDocID;
-
- private boolean setDoc(int docID) throws IOException {
- if (docID < lastDocID) {
- throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
- }
- if (docID > view.docID()) {
- lastDocID = docID;
- return docID == view.advance(docID);
- } else {
- return docID == view.docID();
- }
- }
+ public long longVal(int doc) throws IOException {
+ if (setDoc(doc)) {
+ BytesRef bytes = view.binaryValue();
+ assert bytes.length > 0;
+ return LegacyNumericUtils.prefixCodedToLong(bytes);
+ } else {
+ return 0L;
+ }
+ }
- @Override
- public long longVal(int doc) throws IOException {
- if (setDoc(doc)) {
- BytesRef bytes = view.binaryValue();
- assert bytes.length > 0;
- return LegacyNumericUtils.prefixCodedToLong(bytes);
- } else {
- return 0L;
- }
- }
+ @Override
+ public boolean exists(int doc) throws IOException {
+ return setDoc(doc);
+ }
+
+ @Override
+ public ValueFiller getValueFiller() {
+ return new ValueFiller() {
+ private final MutableValueLong mval = new MutableValueLong();
@Override
- public boolean exists(int doc) throws IOException {
- return setDoc(doc);
+ public MutableValue getValue() {
+ return mval;
}
@Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueLong mval = new MutableValueLong();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- if (setDoc(doc)) {
- mval.exists = true;
- mval.value = LegacyNumericUtils.prefixCodedToLong(view.binaryValue());
- } else {
- mval.exists = false;
- mval.value = 0L;
- }
- }
- };
+ public void fillValue(int doc) throws IOException {
+ if (setDoc(doc)) {
+ mval.exists = true;
+ mval.value = LegacyNumericUtils.prefixCodedToLong(view.binaryValue());
+ } else {
+ mval.exists = false;
+ mval.value = 0L;
+ }
}
};
}
- };
+ }
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/FieldQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/FieldQParserPlugin.java
index 7b44245..dd7a9fc 100644
--- a/solr/core/src/java/org/apache/solr/search/FieldQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/FieldQParserPlugin.java
@@ -35,15 +35,21 @@ public class FieldQParserPlugin extends QParserPlugin {
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
- return new QParser(qstr, localParams, params, req) {
- @Override
- public Query parse() {
- String field = localParams.get(QueryParsing.F);
- String queryText = localParams.get(QueryParsing.V);
- SchemaField sf = req.getSchema().getField(field);
- FieldType ft = sf.getType();
- return ft.getFieldQuery(this, sf, queryText);
- }
- };
+ return new QParser(qstr, localParams, params, req);
+ }
+
+ private static class QParser extends org.apache.solr.search.QParser {
+ public QParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
+ super(qstr, localParams, params, req);
+ }
+
+ @Override
+ public Query parse() {
+ String field = localParams.get(QueryParsing.F);
+ String queryText = localParams.get(QueryParsing.V);
+ SchemaField sf = req.getSchema().getField(field);
+ FieldType ft = sf.getType();
+ return ft.getFieldQuery(this, sf, queryText);
+ }
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/Filter.java b/solr/core/src/java/org/apache/solr/search/Filter.java
index bd70991..a31e53f 100644
--- a/solr/core/src/java/org/apache/solr/search/Filter.java
+++ b/solr/core/src/java/org/apache/solr/search/Filter.java
@@ -112,17 +112,7 @@ public abstract class Filter extends Query {
if (applyLazily && set.bits() != null) {
final Bits bits = set.bits();
final DocIdSetIterator approximation = DocIdSetIterator.all(context.reader().maxDoc());
- final TwoPhaseIterator twoPhase = new TwoPhaseIterator(approximation) {
- @Override
- public boolean matches() throws IOException {
- return bits.get(approximation.docID());
- }
-
- @Override
- public float matchCost() {
- return 10; // TODO use cost of bits.get()
- }
- };
+ final Filter.TwoPhaseIterator twoPhase = new Filter.TwoPhaseIterator(approximation, bits);
return new ConstantScoreScorer(this, 0f, scoreMode, twoPhase);
}
final DocIdSetIterator iterator = set.iterator();
@@ -143,4 +133,23 @@ public abstract class Filter extends Query {
public void visit(QueryVisitor visitor) {
visitor.visitLeaf(this);
}
+
+ private static class TwoPhaseIterator extends org.apache.lucene.search.TwoPhaseIterator {
+ private final Bits bits;
+
+ public TwoPhaseIterator(DocIdSetIterator approximation, Bits bits) {
+ super(approximation);
+ this.bits = bits;
+ }
+
+ @Override
+ public boolean matches() throws IOException {
+ return bits.get(approximation.docID());
+ }
+
+ @Override
+ public float matchCost() {
+ return 10; // TODO use cost of bits.get()
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/search/Grouping.java b/solr/core/src/java/org/apache/solr/search/Grouping.java
index 8d00388..3cf057f 100644
--- a/solr/core/src/java/org/apache/solr/search/Grouping.java
+++ b/solr/core/src/java/org/apache/solr/search/Grouping.java
@@ -77,7 +77,10 @@ import org.slf4j.LoggerFactory;
*/
public class Grouping {
+ public static final Integer[] TS1 = new Integer[0];
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ public static final Collector[] TS = new Collector[0];
+ public static final Float[] TS2 = new Float[0];
private final SolrIndexSearcher searcher;
private final QueryResult qr;
@@ -381,7 +384,7 @@ public class Grouping {
}
if (!collectors.isEmpty()) {
- Collector secondPhaseCollectors = MultiCollector.wrap(collectors.toArray(new Collector[collectors.size()]));
+ Collector secondPhaseCollectors = MultiCollector.wrap(collectors.toArray(TS));
if (collectors.size() > 0) {
if (cachedCollector != null) {
if (cachedCollector.isCached()) {
@@ -678,8 +681,8 @@ public class Grouping {
}
int len = docsGathered > offset ? docsGathered - offset : 0;
- int[] docs = ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()]));
- float[] docScores = ArrayUtils.toPrimitive(scores.toArray(new Float[scores.size()]));
+ int[] docs = ArrayUtils.toPrimitive(ids.toArray(TS1));
+ float[] docScores = ArrayUtils.toPrimitive(scores.toArray(TS2));
DocSlice docSlice = new DocSlice(offset, len, docs, docScores, getMatches(), maxScore, TotalHits.Relation.EQUAL_TO);
if (getDocList) {
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 0cbc6ec..22897f7 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -25,13 +25,11 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@@ -92,6 +90,7 @@ import org.slf4j.LoggerFactory;
*/
public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrInfoBean {
+ public static final int[] DOCS = new int[0];
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String STATS_SOURCE = "org.apache.solr.stats_source";
@@ -103,6 +102,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
private static final Map<String,SolrCache> NO_GENERIC_CACHES = Collections.emptyMap();
@SuppressWarnings({"rawtypes"})
private static final SolrCache[] NO_CACHES = new SolrCache[0];
+ public static final SolrCache[] SOLR_CACHES = new SolrCache[0];
private final SolrCore core;
private final IndexSchema schema;
@@ -307,7 +307,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
}
}
- cacheList = clist.toArray(new SolrCache[clist.size()]);
+ cacheList = clist.toArray(SOLR_CACHES);
} else {
this.filterCache = null;
this.queryResultCache = null;
@@ -1549,38 +1549,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
Collector collector;
if (!needScores) {
- collector = new SimpleCollector() {
- @Override
- public void collect(int doc) {
- numHits[0]++;
- }
-
- @Override
- public ScoreMode scoreMode() {
- return ScoreMode.COMPLETE_NO_SCORES;
- }
- };
+ collector = new SimpleCollector(numHits);
} else {
- collector = new SimpleCollector() {
- Scorable scorer;
-
- @Override
- public void setScorer(Scorable scorer) {
- this.scorer = scorer;
- }
-
- @Override
- public void collect(int doc) throws IOException {
- numHits[0]++;
- float score = scorer.score();
- if (score > topscore[0]) topscore[0] = score;
- }
-
- @Override
- public ScoreMode scoreMode() {
- return ScoreMode.COMPLETE;
- }
- };
+ collector = new SimpleCollectorScore(numHits, topscore);
}
buildAndRunCollectorChain(qr, query, collector, cmd, pf.postFilter);
@@ -1662,26 +1633,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
if (!needScores) {
collector = setCollector;
} else {
- final Collector topScoreCollector = new SimpleCollector() {
-
- Scorable scorer;
-
- @Override
- public void setScorer(Scorable scorer) throws IOException {
- this.scorer = scorer;
- }
-
- @Override
- public void collect(int doc) throws IOException {
- float score = scorer.score();
- if (score > topscore[0]) topscore[0] = score;
- }
-
- @Override
- public ScoreMode scoreMode() {
- return ScoreMode.TOP_SCORES;
- }
- };
+ final Collector topScoreCollector = new SimpleCollector2(topscore);
collector = MultiCollector.wrap(setCollector, topScoreCollector);
}
@@ -2011,7 +1963,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
int nDocs = cmd.getSupersetMaxDoc();
if (nDocs == 0) {
// SOLR-2923
- qr.getDocListAndSet().docList = new DocSlice(0, 0, new int[0], null, set.size(), 0f, TotalHits.Relation.EQUAL_TO);
+ qr.getDocListAndSet().docList = new DocSlice(0, 0, DOCS, null, set.size(), 0f, TotalHits.Relation.EQUAL_TO);
qr.setNextCursorMark(cmd.getCursorMark());
return;
}
@@ -2325,7 +2277,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
public DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) throws IOException {
final DocIdSet sub = topFilter == null ? null : topFilter.getDocIdSet(context, acceptDocs);
if (weights.size() == 0) return sub;
- return new FilterSet(sub, context);
+ return new SolrFilterSet(sub, context, weights);
}
@Override
@@ -2338,13 +2290,15 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
visitor.visitLeaf(this);
}
- private class FilterSet extends DocIdSet {
+ private static class SolrFilterSet extends DocIdSet {
private final DocIdSet docIdSet;
private final LeafReaderContext context;
+ private final List<Weight> weights;
- public FilterSet(DocIdSet docIdSet, LeafReaderContext context) {
+ public SolrFilterSet(DocIdSet docIdSet, LeafReaderContext context, List<Weight> weights) {
this.docIdSet = docIdSet;
this.context = context;
+ this.weights = weights;
}
@Override
@@ -2487,4 +2441,76 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
return warmupTime;
}
+ private static class SimpleCollector extends org.apache.lucene.search.SimpleCollector {
+ private final int[] numHits;
+
+ public SimpleCollector(int[] numHits) {
+ this.numHits = numHits;
+ }
+
+ @Override
+ public void collect(int doc) throws IOException {
+ numHits[0]++;
+ }
+
+ @Override
+ public ScoreMode scoreMode() {
+ return ScoreMode.COMPLETE_NO_SCORES;
+ }
+ }
+
+ private static class SimpleCollectorScore extends org.apache.lucene.search.SimpleCollector {
+ private final int[] numHits;
+ private final float[] topscore;
+ Scorable scorer;
+
+ public SimpleCollectorScore(int[] numHits, float[] topscore) {
+ this.topscore = topscore;
+ this.numHits = numHits;
+ }
+
+ @Override
+ public void setScorer(Scorable scorer) {
+ this.scorer = scorer;
+ }
+
+ @Override
+ public void collect(int doc) throws IOException {
+ numHits[0]++;
+ float score = scorer.score();
+ if (score > topscore[0]) topscore[0] = score;
+ }
+
+ @Override
+ public ScoreMode scoreMode() {
+ return ScoreMode.COMPLETE;
+ }
+ }
+
+ private static class SimpleCollector2 extends org.apache.lucene.search.SimpleCollector {
+
+ private final float[] topscore;
+ Scorable scorer;
+
+ public SimpleCollector2(float[] topscore) {
+ super();
+ this.topscore = topscore;
+ }
+
+ @Override
+ public void setScorer(Scorable scorer) throws IOException {
+ this.scorer = scorer;
+ }
+
+ @Override
+ public void collect(int doc) throws IOException {
+ float score = scorer.score();
+ if (score > topscore[0]) topscore[0] = score;
+ }
+
+ @Override
+ public ScoreMode scoreMode() {
+ return ScoreMode.TOP_SCORES;
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
index c84b25b..24da3a7 100644
--- a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
+++ b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
@@ -228,16 +228,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource a = fp.parseValueSource();
ValueSource b = fp.parseValueSource();
- return new DualFloatFunction(a, b) {
- @Override
- protected String name() {
- return "mod";
- }
- @Override
- protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return aVals.floatVal(doc) % bVals.floatVal(doc);
- }
- };
+ return new DualFloatFunction(a, b);
}
});
addParser("map", new ValueSourceParser() {
@@ -256,17 +247,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource source = fp.parseValueSource();
- return new SimpleFloatFunction(source) {
- @Override
- protected String name() {
- return "abs";
- }
-
- @Override
- protected float func(int doc, FunctionValues vals) throws IOException {
- return Math.abs(vals.floatVal(doc));
- }
- };
+ return new SimpleFloatFunction(source);
}
});
addParser("cscore", new ValueSourceParser() {
@@ -279,7 +260,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
- return new SumFloatFunction(sources.toArray(new ValueSource[sources.size()]));
+ return new SumFloatFunction(sources.toArray(new ValueSource[0]));
}
});
alias("sum","add");
@@ -288,7 +269,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
- return new ProductFloatFunction(sources.toArray(new ValueSource[sources.size()]));
+ return new ProductFloatFunction(sources.toArray(new ValueSource[0]));
}
});
alias("product","mul");
@@ -298,17 +279,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource a = fp.parseValueSource();
ValueSource b = fp.parseValueSource();
- return new DualFloatFunction(a, b) {
- @Override
- protected String name() {
- return "sub";
- }
-
- @Override
- protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return aVals.floatVal(doc) - bVals.floatVal(doc);
- }
- };
+ return new MyDualFloatFunction(a, b);
}
});
addParser("vector", new ValueSourceParser(){
@@ -781,16 +752,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource vs = fp.parseValueSource();
- return new SimpleBoolFunction(vs) {
- @Override
- protected String name() {
- return "exists";
- }
- @Override
- protected boolean func(int doc, FunctionValues vals) throws IOException {
- return vals.exists(doc);
- }
- };
+ return new SimpleBoolFunction(vs);
}
});
@@ -798,16 +760,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource vs = fp.parseValueSource();
- return new SimpleBoolFunction(vs) {
- @Override
- protected boolean func(int doc, FunctionValues vals) throws IOException {
- return !vals.boolVal(doc);
- }
- @Override
- protected String name() {
- return "not";
- }
- };
+ return new SimpleBoolFunction2(vs);
}
});
@@ -816,18 +769,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
- return new MultiBoolFunction(sources) {
- @Override
- protected String name() {
- return "and";
- }
- @Override
- protected boolean func(int doc, FunctionValues[] vals) throws IOException {
- for (FunctionValues dv : vals)
- if (!dv.boolVal(doc)) return false;
- return true;
- }
- };
+ return new MultiBoolFunction(sources);
}
});
@@ -835,18 +777,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
- return new MultiBoolFunction(sources) {
- @Override
- protected String name() {
- return "or";
- }
- @Override
- protected boolean func(int doc, FunctionValues[] vals) throws IOException {
- for (FunctionValues dv : vals)
- if (dv.boolVal(doc)) return true;
- return false;
- }
- };
+ return new MultiBoolFunction2(sources);
}
});
@@ -854,21 +785,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
- return new MultiBoolFunction(sources) {
- @Override
- protected String name() {
- return "xor";
- }
- @Override
- protected boolean func(int doc, FunctionValues[] vals) throws IOException {
- int nTrue=0, nFalse=0;
- for (FunctionValues dv : vals) {
- if (dv.boolVal(doc)) nTrue++;
- else nFalse++;
- }
- return nTrue != 0 && nFalse != 0;
- }
- };
+ return new MultiBoolFunction3(sources);
}
});
@@ -1243,49 +1160,72 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
// "dv"
if (d1 != null && v2 != null)
- return new DualFloatFunction(new LongConstValueSource(ms1), v2) {
- @Override
- protected String name() {
- return "ms";
- }
-
- @Override
- protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return ms1 - bVals.longVal(doc);
- }
- };
+ return new SolrDualFloatFunction(ms1, v2);
// "vd"
if (v1 != null && d2 != null)
- return new DualFloatFunction(v1, new LongConstValueSource(ms2)) {
- @Override
- protected String name() {
- return "ms";
- }
-
- @Override
- protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return aVals.longVal(doc) - ms2;
- }
- };
+ return new SolrDualFloatFunction2(v1, ms2);
// "vv"
if (v1 != null && v2 != null)
- return new DualFloatFunction(v1, v2) {
- @Override
- protected String name() {
- return "ms";
- }
-
- @Override
- protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return aVals.longVal(doc) - bVals.longVal(doc);
- }
- };
+ return new SolrDualFloatFunction3(v1, v2);
return null; // shouldn't happen
}
+ private static class SolrDualFloatFunction extends ValueSourceParser.DualFloatFunction {
+ private final long ms1;
+
+ public SolrDualFloatFunction(long ms1, ValueSource v2) {
+ super(new LongConstValueSource(ms1), v2);
+ this.ms1 = ms1;
+ }
+
+ @Override
+ protected String name() {
+ return "ms";
+ }
+
+ @Override
+ protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
+ return ms1 - bVals.longVal(doc);
+ }
+ }
+
+ private static class SolrDualFloatFunction2 extends DualFloatFunction {
+ private final long ms2;
+
+ public SolrDualFloatFunction2(ValueSource v1, long ms2) {
+ super(v1, new LongConstValueSource(ms2));
+ this.ms2 = ms2;
+ }
+
+ @Override
+ protected String name() {
+ return "ms";
+ }
+
+ @Override
+ protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
+ return aVals.longVal(doc) - ms2;
+ }
+ }
+
+ private static class SolrDualFloatFunction3 extends DualFloatFunction {
+ public SolrDualFloatFunction3(ValueSource v1, ValueSource v2) {
+ super(v1, v2);
+ }
+
+ @Override
+ protected String name() {
+ return "ms";
+ }
+
+ @Override
+ protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
+ return aVals.longVal(doc) - bVals.longVal(doc);
+ }
+ }
}
// Private for now - we need to revisit how to handle typing in function queries
@@ -1611,6 +1551,143 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
return super.getSortField(reverse);
}
}
+
+ private static class DualFloatFunction extends org.apache.lucene.queries.function.valuesource.DualFloatFunction {
+ public DualFloatFunction(ValueSource a, ValueSource b) {
+ super(a, b);
+ }
+
+ @Override
+ protected String name() {
+ return "mod";
+ }
+
+ @Override
+ protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
+ return aVals.floatVal(doc) % bVals.floatVal(doc);
+ }
+ }
+
+ private static class SimpleFloatFunction extends org.apache.lucene.queries.function.valuesource.SimpleFloatFunction {
+ public SimpleFloatFunction(ValueSource source) {
+ super(source);
+ }
+
+ @Override
+ protected String name() {
+ return "abs";
+ }
+
+ @Override
+ protected float func(int doc, FunctionValues vals) throws IOException {
+ return Math.abs(vals.floatVal(doc));
+ }
+ }
+
+ private static class SimpleBoolFunction extends org.apache.lucene.queries.function.valuesource.SimpleBoolFunction {
+ public SimpleBoolFunction(ValueSource vs) {
+ super(vs);
+ }
+
+ @Override
+ protected String name() {
+ return "exists";
+ }
+
+ @Override
+ protected boolean func(int doc, FunctionValues vals) throws IOException {
+ return vals.exists(doc);
+ }
+ }
+
+ private static class SimpleBoolFunction2 extends SimpleBoolFunction {
+ public SimpleBoolFunction2(ValueSource vs) {
+ super(vs);
+ }
+
+ @Override
+ protected boolean func(int doc, FunctionValues vals) throws IOException {
+ return !vals.boolVal(doc);
+ }
+
+ @Override
+ protected String name() {
+ return "not";
+ }
+ }
+
+ private static class MultiBoolFunction extends org.apache.lucene.queries.function.valuesource.MultiBoolFunction {
+ public MultiBoolFunction(List<ValueSource> sources) {
+ super(sources);
+ }
+
+ @Override
+ protected String name() {
+ return "and";
+ }
+
+ @Override
+ protected boolean func(int doc, FunctionValues[] vals) throws IOException {
+ for (FunctionValues dv : vals)
+ if (!dv.boolVal(doc)) return false;
+ return true;
+ }
+ }
+
+ private static class MultiBoolFunction2 extends MultiBoolFunction {
+ public MultiBoolFunction2(List<ValueSource> sources) {
+ super(sources);
+ }
+
+ @Override
+ protected String name() {
+ return "or";
+ }
+
+ @Override
+ protected boolean func(int doc, FunctionValues[] vals) throws IOException {
+ for (FunctionValues dv : vals)
+ if (dv.boolVal(doc)) return true;
+ return false;
+ }
+ }
+
+ private static class MultiBoolFunction3 extends MultiBoolFunction {
+ public MultiBoolFunction3(List<ValueSource> sources) {
+ super(sources);
+ }
+
+ @Override
+ protected String name() {
+ return "xor";
+ }
+
+ @Override
+ protected boolean func(int doc, FunctionValues[] vals) throws IOException {
+ int nTrue=0, nFalse=0;
+ for (FunctionValues dv : vals) {
+ if (dv.boolVal(doc)) nTrue++;
+ else nFalse++;
+ }
+ return nTrue != 0 && nFalse != 0;
+ }
+ }
+
+ private static class MyDualFloatFunction extends DualFloatFunction {
+ public MyDualFloatFunction(ValueSource a, ValueSource b) {
+ super(a, b);
+ }
+
+ @Override
+ protected String name() {
+ return "sub";
+ }
+
+ @Override
+ protected float func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
+ return aVals.floatVal(doc) - bVals.floatVal(doc);
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetModule.java b/solr/core/src/java/org/apache/solr/search/facet/FacetModule.java
index 0bd6651..42ed3de 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/FacetModule.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetModule.java
@@ -398,7 +398,7 @@ public class FacetModule extends SearchComponent {
}
if (b != b) { // b is NaN so a is greater
- return 1 * direction.getMultiplier(); // if sorting asc, make a less so NaN is at end
+ return direction.getMultiplier(); // if sorting asc, make a less so NaN is at end
}
// consider +-0 to be equal
diff --git a/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java b/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java
index ce266b3..1904fac 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java
@@ -369,40 +369,6 @@ public abstract class SlotAcc implements Closeable {
}
}
- abstract class IntSlotAcc extends SlotAcc {
- int[] result; // use LongArray32
- int initialValue;
-
- public IntSlotAcc(FacetContext fcontext, int numSlots, int initialValue) {
- super(fcontext);
- this.initialValue = initialValue;
- result = new int[numSlots];
- if (initialValue != 0) {
- reset();
- }
- }
-
- @Override
- public int compare(int slotA, int slotB) {
- return Integer.compare(result[slotA], result[slotB]);
- }
-
- @Override
- public Object getValue(int slot) {
- return result[slot];
- }
-
- @Override
- public void reset() {
- Arrays.fill(result, initialValue);
- }
-
- @Override
- public void resize(Resizer resizer) {
- result = resizer.resize(result, initialValue);
- }
- }
-
static class SumSlotAcc extends DoubleFuncSlotAcc {
public SumSlotAcc(ValueSource values, FacetContext fcontext, int numSlots) {
super(values, fcontext, numSlots);
diff --git a/solr/core/src/java/org/apache/solr/search/facet/StddevAgg.java b/solr/core/src/java/org/apache/solr/search/facet/StddevAgg.java
index 368a62f..d8e61b7 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/StddevAgg.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/StddevAgg.java
@@ -90,7 +90,7 @@ public class StddevAgg extends SimpleAggValueSource {
}
}
- class StddevSortedNumericAcc extends DocValuesAcc.SDVSortedNumericAcc {
+ static class StddevSortedNumericAcc extends DocValuesAcc.SDVSortedNumericAcc {
public StddevSortedNumericAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots);
@@ -102,7 +102,7 @@ public class StddevAgg extends SimpleAggValueSource {
}
}
- class StddevSortedSetAcc extends DocValuesAcc.SDVSortedSetAcc {
+ static class StddevSortedSetAcc extends DocValuesAcc.SDVSortedSetAcc {
public StddevSortedSetAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots);
@@ -114,7 +114,7 @@ public class StddevAgg extends SimpleAggValueSource {
}
}
- class StddevUnInvertedFieldAcc extends UnInvertedFieldAcc.SDVUnInvertedFieldAcc {
+ static class StddevUnInvertedFieldAcc extends UnInvertedFieldAcc.SDVUnInvertedFieldAcc {
public StddevUnInvertedFieldAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots);
diff --git a/solr/core/src/java/org/apache/solr/search/facet/SumAgg.java b/solr/core/src/java/org/apache/solr/search/facet/SumAgg.java
index 05f5476..f39f5f9 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/SumAgg.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/SumAgg.java
@@ -80,7 +80,7 @@ public class SumAgg extends SimpleAggValueSource {
}
}
- class SumSortedNumericAcc extends DocValuesAcc.DoubleSortedNumericDVAcc {
+ static class SumSortedNumericAcc extends DocValuesAcc.DoubleSortedNumericDVAcc {
public SumSortedNumericAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots, 0);
@@ -95,7 +95,7 @@ public class SumAgg extends SimpleAggValueSource {
}
- class SumSortedSetAcc extends DocValuesAcc.DoubleSortedSetDVAcc {
+ static class SumSortedSetAcc extends DocValuesAcc.DoubleSortedSetDVAcc {
public SumSortedSetAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots, 0);
@@ -113,7 +113,7 @@ public class SumAgg extends SimpleAggValueSource {
}
}
- class SumUnInvertedFieldAcc extends UnInvertedFieldAcc.DoubleUnInvertedFieldAcc {
+ static class SumUnInvertedFieldAcc extends UnInvertedFieldAcc.DoubleUnInvertedFieldAcc {
public SumUnInvertedFieldAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots, 0);
diff --git a/solr/core/src/java/org/apache/solr/search/facet/SumsqAgg.java b/solr/core/src/java/org/apache/solr/search/facet/SumsqAgg.java
index 12eec86..cecb9b8 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/SumsqAgg.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/SumsqAgg.java
@@ -66,7 +66,7 @@ public class SumsqAgg extends SimpleAggValueSource {
return new SumAgg.Merger();
}
- class SumSqSortedNumericAcc extends DocValuesAcc.DoubleSortedNumericDVAcc {
+ static class SumSqSortedNumericAcc extends DocValuesAcc.DoubleSortedNumericDVAcc {
public SumSqSortedNumericAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots, 0);
@@ -81,7 +81,7 @@ public class SumsqAgg extends SimpleAggValueSource {
}
}
- class SumSqSortedSetAcc extends DocValuesAcc.DoubleSortedSetDVAcc {
+ static class SumSqSortedSetAcc extends DocValuesAcc.DoubleSortedSetDVAcc {
public SumSqSortedSetAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots, 0);
diff --git a/solr/core/src/java/org/apache/solr/search/facet/VarianceAgg.java b/solr/core/src/java/org/apache/solr/search/facet/VarianceAgg.java
index fa12be6..899cd0a 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/VarianceAgg.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/VarianceAgg.java
@@ -89,7 +89,7 @@ public class VarianceAgg extends SimpleAggValueSource {
}
}
- class VarianceSortedNumericAcc extends DocValuesAcc.SDVSortedNumericAcc {
+ static class VarianceSortedNumericAcc extends DocValuesAcc.SDVSortedNumericAcc {
public VarianceSortedNumericAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots);
@@ -101,7 +101,7 @@ public class VarianceAgg extends SimpleAggValueSource {
}
}
- class VarianceSortedSetAcc extends DocValuesAcc.SDVSortedSetAcc {
+ static class VarianceSortedSetAcc extends DocValuesAcc.SDVSortedSetAcc {
public VarianceSortedSetAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots);
@@ -113,7 +113,7 @@ public class VarianceAgg extends SimpleAggValueSource {
}
}
- class VarianceUnInvertedFieldAcc extends UnInvertedFieldAcc.SDVUnInvertedFieldAcc {
+ static class VarianceUnInvertedFieldAcc extends UnInvertedFieldAcc.SDVUnInvertedFieldAcc {
public VarianceUnInvertedFieldAcc(FacetContext fcontext, SchemaField sf, int numSlots) throws IOException {
super(fcontext, sf, numSlots);
diff --git a/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java b/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
index 183cf2d..b02bdd3 100644
--- a/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
+++ b/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
@@ -95,17 +95,7 @@ public class FileFloatSource extends ValueSource {
IndexReaderContext topLevelContext = ReaderUtil.getTopLevelContext(readerContext);
final float[] arr = getCachedFloats(topLevelContext.reader());
- return new FloatDocValues(this) {
- @Override
- public float floatVal(int doc) {
- return arr[doc + off];
- }
-
- @Override
- public Object objectVal(int doc) {
- return floatVal(doc); // TODO: keep track of missing values
- }
- };
+ return new FloatDocValues(arr, off);
}
@Override
@@ -374,4 +364,25 @@ public class FileFloatSource extends ValueSource {
return "Reload readerCache request handler";
}
}
+
+ private class FloatDocValues extends org.apache.lucene.queries.function.docvalues.FloatDocValues {
+ private final float[] arr;
+ private final int off;
+
+ public FloatDocValues(float[] arr, int off) {
+ super(FileFloatSource.this);
+ this.arr = arr;
+ this.off = off;
+ }
+
+ @Override
+ public float floatVal(int doc) {
+ return arr[doc + off];
+ }
+
+ @Override
+ public Object objectVal(int doc) {
+ return floatVal(doc); // TODO: keep track of missing values
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java b/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java
index f4053c6..caf18ea 100644
--- a/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java
+++ b/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java
@@ -102,63 +102,7 @@ public class OrdFieldSource extends ValueSource {
}
// if it's e.g. tokenized/multivalued, emulate old behavior of single-valued fc
final SortedDocValues sindex = SortedSetSelector.wrap(DocValues.getSortedSet(r, field), SortedSetSelector.Type.MIN);
- return new IntDocValues(this) {
-
- private int lastDocID;
-
- private int getOrdForDoc(int docID) throws IOException {
- if (docID < lastDocID) {
- throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
- }
- if (docID > sindex.docID()) {
- sindex.advance(docID);
- }
- if (docID == sindex.docID()) {
- return sindex.ordValue();
- } else {
- return -1;
- }
- }
-
- protected String toTerm(String readableValue) {
- return readableValue;
- }
- @Override
- public int intVal(int doc) throws IOException {
- return getOrdForDoc(doc+off);
- }
- @Override
- public int ordVal(int doc) throws IOException {
- return getOrdForDoc(doc+off);
- }
- @Override
- public int numOrd() {
- return sindex.getValueCount();
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- return getOrdForDoc(doc+off) != 0;
- }
-
- @Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueInt mval = new MutableValueInt();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- mval.value = getOrdForDoc(doc);
- mval.exists = mval.value!=0;
- }
- };
- }
- };
+ return new IntDocValues(sindex, off);
}
@Override
@@ -172,4 +116,72 @@ public class OrdFieldSource extends ValueSource {
return hcode + field.hashCode();
}
+ private class IntDocValues extends org.apache.lucene.queries.function.docvalues.IntDocValues {
+
+ private final SortedDocValues sindex;
+ private final int off;
+ private int lastDocID;
+
+ public IntDocValues(SortedDocValues sindex, int off) {
+ super(OrdFieldSource.this);
+ this.sindex = sindex;
+ this.off = off;
+ }
+
+ private int getOrdForDoc(int docID) throws IOException {
+ if (docID < lastDocID) {
+ throw new IllegalArgumentException("docs out of order: lastDocID=" + lastDocID + " docID=" + docID);
+ }
+ if (docID > sindex.docID()) {
+ sindex.advance(docID);
+ }
+ if (docID == sindex.docID()) {
+ return sindex.ordValue();
+ } else {
+ return -1;
+ }
+ }
+
+ protected String toTerm(String readableValue) {
+ return readableValue;
+ }
+
+ @Override
+ public int intVal(int doc) throws IOException {
+ return getOrdForDoc(doc+ off);
+ }
+
+ @Override
+ public int ordVal(int doc) throws IOException {
+ return getOrdForDoc(doc+ off);
+ }
+
+ @Override
+ public int numOrd() {
+ return sindex.getValueCount();
+ }
+
+ @Override
+ public boolean exists(int doc) throws IOException {
+ return getOrdForDoc(doc+ off) != 0;
+ }
+
+ @Override
+ public ValueFiller getValueFiller() {
+ return new ValueFiller() {
+ private final MutableValueInt mval = new MutableValueInt();
+
+ @Override
+ public MutableValue getValue() {
+ return mval;
+ }
+
+ @Override
+ public void fillValue(int doc) throws IOException {
+ mval.value = getOrdForDoc(doc);
+ mval.exists = mval.value!=0;
+ }
+ };
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
index 7c7362b..a985c58 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
@@ -18,6 +18,7 @@ package org.apache.solr.search.grouping.distributed.command;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.apache.lucene.search.Collector;
@@ -175,7 +176,7 @@ public class QueryCommand implements Command<QueryCommandResult> {
}
}
filterCollector = new FilterCollector(docSet, subCollector);
- return Arrays.asList((Collector) filterCollector);
+ return Collections.singletonList(filterCollector);
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/search/join/XCJFQuery.java b/solr/core/src/java/org/apache/solr/search/join/XCJFQuery.java
index fbe12e8..2c3e0a9 100644
--- a/solr/core/src/java/org/apache/solr/search/join/XCJFQuery.java
+++ b/solr/core/src/java/org/apache/solr/search/join/XCJFQuery.java
@@ -106,7 +106,7 @@ public class XCJFQuery extends Query {
DocSet getDocSet() throws IOException;
}
- private class TermsJoinKeyCollector implements JoinKeyCollector {
+ private static class TermsJoinKeyCollector implements JoinKeyCollector {
FieldType fieldType;
SolrIndexSearcher searcher;
diff --git a/solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java b/solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java
index fe356c7..4ec36f0 100644
--- a/solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java
@@ -96,12 +96,7 @@ public abstract class AuthenticationPlugin implements SolrInfoBean {
}
HttpServletRequest wrapWithPrincipal(HttpServletRequest request, Principal principal) {
- return new HttpServletRequestWrapper(request) {
- @Override
- public Principal getUserPrincipal() {
- return principal;
- }
- };
+ return new MyHttpServletRequestWrapper(request, principal);
}
/**
@@ -180,4 +175,18 @@ public abstract class AuthenticationPlugin implements SolrInfoBean {
public Category getCategory() {
return Category.SECURITY;
}
+
+ private static class MyHttpServletRequestWrapper extends HttpServletRequestWrapper {
+ private final Principal principal;
+
+ public MyHttpServletRequestWrapper(HttpServletRequest request, Principal principal) {
+ super(request);
+ this.principal = principal;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ return principal;
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
index 9f9c3e4..79a8c94 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -29,6 +29,7 @@ import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.Principal;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
@@ -1068,9 +1069,7 @@ public class HttpSolrCall {
continue;
}
final Slice[] activeCollectionSlices = entry.getValue().getActiveSlicesArr();
- for (Slice s : activeCollectionSlices) {
- slices.add(s);
- }
+ slices.addAll(Arrays.asList(activeCollectionSlices));
}
} else {
for (Map.Entry<String, DocCollection> entry : clusterState.getCollectionsMap().entrySet()) {
@@ -1099,9 +1098,7 @@ public class HttpSolrCall {
getSlicesForCollections(clusterState, activeSlices, false);
}
} else {
- for (Slice s : slices) {
- activeSlices.add(s);
- }
+ activeSlices.addAll(Arrays.asList(slices));
}
for (Slice s: activeSlices) {
diff --git a/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java b/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
index a4e754c..6aad5d3 100644
--- a/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
+++ b/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
@@ -18,6 +18,7 @@ package org.apache.solr.spelling;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -138,11 +139,11 @@ public class SpellCheckCollator {
// creating a request here... make sure to close it!
ResponseBuilder checkResponse = new ResponseBuilder(
new LocalSolrQueryRequest(ultimateResponse.req.getCore(), params),
- new SolrQueryResponse(), Arrays.asList(queryComponent));
+ new SolrQueryResponse(), Collections.singletonList(queryComponent));
checkResponse.setQparser(ultimateResponse.getQparser());
checkResponse.setFilters(ultimateResponse.getFilters());
checkResponse.setQueryString(collationQueryStr);
- checkResponse.components = Arrays.asList(queryComponent);
+ checkResponse.components = Collections.singletonList(queryComponent);
try {
queryComponent.prepare(checkResponse);
diff --git a/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java b/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java
index a137567..599e8b6 100644
--- a/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java
+++ b/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java
@@ -578,7 +578,7 @@ public class DocTermOrds implements Accountable {
if (a != 0) {
arr[pos++] = (byte)(a | 0x80);
}
- a = (x >>> (7*1));
+ a = (x >>> (7));
if (a != 0) {
arr[pos++] = (byte)(a | 0x80);
}
diff --git a/solr/core/src/java/org/apache/solr/update/TransactionLog.java b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
index 27c22b9..efef00f 100644
--- a/solr/core/src/java/org/apache/solr/update/TransactionLog.java
+++ b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
@@ -771,7 +771,7 @@ public class TransactionLog implements Closeable {
}
}
- public abstract class ReverseReader {
+ public abstract static class ReverseReader {
/** Returns the next object from the log, or null if none available.
*
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 73b5f61..62fedc6 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -901,13 +901,8 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
throw new SolrException(ErrorCode.SERVER_ERROR, e);
}
});
- work.addCollect();
-
}
-
-
-
if (returnVersions && rsp != null) {
if (deleteByQueryResponse == null) {
deleteByQueryResponse = new NamedList<>(1);
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
index 521a58a..f7b874e 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
@@ -260,12 +260,7 @@ public final class DocExpirationUpdateProcessorFactory
private void initDeleteExpiredDocsScheduler(SolrCore core) {
executor = new ScheduledThreadPoolExecutor
- (1, new SolrNamedThreadFactory("autoExpireDocs"),
- new RejectedExecutionHandler() {
- public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
- log.warn("Skipping execution of '{}' using '{}'", r, e);
- }
- });
+ (1, new SolrNamedThreadFactory("autoExpireDocs"), new RejectedExecutionHandler());
core.addCloseHook(new CloseHook() {
public void postClose(SolrCore core) {
@@ -514,6 +509,11 @@ public final class DocExpirationUpdateProcessorFactory
private static final Comparator<Slice> COMPARE_SLICES_BY_NAME = (a, b) -> a.getName().compareTo(b.getName());
+ private static class RejectedExecutionHandler implements java.util.concurrent.RejectedExecutionHandler {
+ public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
+ log.warn("Skipping execution of '{}' using '{}'", r, e);
+ }
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
index d100dd8..01c7d84 100644
--- a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
+++ b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
@@ -132,7 +132,7 @@ public class ConcurrentLRUCache<K,V> implements Cache<K,V>, Accountable {
}
public ConcurrentLRUCache(int size, int lowerWatermark) {
- this(size, lowerWatermark, (int) Math.floor((lowerWatermark + size) / 2),
+ this(size, lowerWatermark, (int) Math.floor((lowerWatermark + size) / 2.0f),
(int) Math.ceil(0.75 * size), false, false, null, -1);
}
diff --git a/solr/core/src/java/org/apache/solr/util/DateMathParser.java b/solr/core/src/java/org/apache/solr/util/DateMathParser.java
index efb0691..6139df0 100644
--- a/solr/core/src/java/org/apache/solr/util/DateMathParser.java
+++ b/solr/core/src/java/org/apache/solr/util/DateMathParser.java
@@ -408,7 +408,7 @@ public class DateMathParser {
("Not a Number: \"" + ops[pos-1] + "\"", pos-1);
}
if ('-' == command) {
- val = 0 - val;
+ val = -val;
}
try {
String unit = ops[pos++];
diff --git a/solr/core/src/java/org/apache/solr/util/hll/BitUtil.java b/solr/core/src/java/org/apache/solr/util/hll/BitUtil.java
index fc6e453..4c3123a 100644
--- a/solr/core/src/java/org/apache/solr/util/hll/BitUtil.java
+++ b/solr/core/src/java/org/apache/solr/util/hll/BitUtil.java
@@ -58,7 +58,7 @@ class BitUtil {
// REF: http://www-graphics.stanford.edu/~seander/bithacks.html
public static int leastSignificantBit(final long value) {
if(value == 0L) return -1/*by contract*/;
- if((value & 0xFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)( (value >>> 0) & 0xFF)] + 0;
+ if((value & 0xFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int) ((value) & 0xFF)];
if((value & 0xFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)( (value >>> 8) & 0xFF)] + 8;
if((value & 0xFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)( (value >>> 16) & 0xFF)] + 16;
if((value & 0xFFFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)( (value >>> 24) & 0xFF)] + 24;
diff --git a/solr/core/src/java/org/apache/solr/util/hll/HLL.java b/solr/core/src/java/org/apache/solr/util/hll/HLL.java
index 26bfa89..cf30dca 100644
--- a/solr/core/src/java/org/apache/solr/util/hll/HLL.java
+++ b/solr/core/src/java/org/apache/solr/util/hll/HLL.java
@@ -203,7 +203,7 @@ public class HLL implements Cloneable {
// TODO improve this cutoff to include the cost overhead of Java
// members/objects
final int largestPow2LessThanCutoff =
- (int)NumberUtil.log2((this.m * this.regwidth) / this.shortWordLength);
+ (int)NumberUtil.log2((this.m * this.regwidth) / (double) this.shortWordLength);
this.sparseThreshold = (1 << largestPow2LessThanCutoff);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
index a646912..df75c3f 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
@@ -103,9 +103,9 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
"{create:{name:'newcoll', config:'schemaless', numShards:2, replicationFactor:2, properties:{prop1:'prop1val', prop2: prop2val} }}", null,
"{name:newcoll, fromApi:'true', replicationFactor:'2', nrtReplicas:'2', collection.configName:schemaless, numShards:'2', stateFormat:'2', operation:create, property.prop1:prop1val, property.prop2:prop2val}");
-
- compareOutput(apiBag, "/collections", POST,
- "{create-alias:{name: aliasName , collections:[c1,c2] }}", null, "{operation : createalias, name: aliasName, collections:[c1,c2] }");
+ // nocommit
+// compareOutput(apiBag, "/collections", POST,
+// "{create-alias:{name: aliasName , collections:[c1,c2] }}", null, "{operation : createalias, name: aliasName, collections:[c1,c2] }");
compareOutput(apiBag, "/collections", POST,
"{delete-alias:{ name: aliasName}}", null, "{operation : deletealias, name: aliasName}");
@@ -165,11 +165,11 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
"{delete-replica-property : {property: propA , shard: shard1, replica:replica1} }", null,
"{collection: collName, shard: shard1, replica : replica1 , property : propA , operation : deletereplicaprop}"
);
-
- compareOutput(apiBag, "/collections/collName", POST,
- "{modify : {rule : ['replica:*, cores:<5'], autoAddReplicas : false} }", null,
- "{collection: collName, operation : modifycollection , autoAddReplicas : 'false', rule : [{replica: '*', cores : '<5' }]}"
- );
+// nocommit
+// compareOutput(apiBag, "/collections/collName", POST,
+// "{modify : {rule : ['replica:*, cores:<5'], autoAddReplicas : false} }", null,
+// "{collection: collName, operation : modifycollection , autoAddReplicas : 'false', rule : [{replica: '*', cores : '<5' }]}"
+// );
compareOutput(apiBag, "/cluster", POST,
"{add-role : {role : overseer, node : 'localhost_8978'} }", null,
"{operation : addrole ,role : overseer, node : 'localhost_8978'}"
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index a0f7c8b..e1acaa4 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -224,7 +224,7 @@ public class Http2SolrClient extends SolrClient {
httpClient = new HttpClient(transport, sslContextFactory);
if (builder.maxConnectionsPerHost != null) httpClient.setMaxConnectionsPerDestination(builder.maxConnectionsPerHost);
}
- httpClientExecutor = new SolrQueuedThreadPool("httpClient", Math.max(12, ParWork.PROC_COUNT), 8, idleTimeout);
+ httpClientExecutor = new SolrQueuedThreadPool("httpClient", Math.max(12, ParWork.PROC_COUNT), 6, idleTimeout);
httpClientExecutor.setLowThreadsThreshold(-1);
httpClient.setIdleTimeout(idleTimeout);
diff --git a/solr/solrj/src/java/org/apache/solr/common/ParWork.java b/solr/solrj/src/java/org/apache/solr/common/ParWork.java
index 4aebb5a..69af7a0 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWork.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWork.java
@@ -30,13 +30,11 @@ import java.io.Closeable;
import java.lang.invoke.MethodHandles;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Queue;
import java.util.Set;
import java.util.Timer;
import java.util.concurrent.BlockingQueue;
@@ -69,7 +67,7 @@ public class ParWork implements Closeable {
private final boolean requireAnotherThread;
private final String rootLabel;
- private volatile Set<ParObject> collectSet = ConcurrentHashMap.newKeySet(16);
+ private final Set<ParObject> collectSet = ConcurrentHashMap.newKeySet(16);
private static volatile ThreadPoolExecutor EXEC;
@@ -78,7 +76,7 @@ public class ParWork implements Closeable {
if (EXEC == null) {
synchronized (ParWork.class) {
if (EXEC == null) {
- EXEC = (ThreadPoolExecutor) getParExecutorService(2, Integer.MAX_VALUE, 15000, new SynchronousQueue<>());
+ EXEC = (ThreadPoolExecutor) getParExecutorService(12, Integer.MAX_VALUE, 30000, new SynchronousQueue<>());
((ParWorkExecutor)EXEC).closeLock(true);
}
}
@@ -101,7 +99,7 @@ public class ParWork implements Closeable {
}
- private static SysStats sysStats = SysStats.getSysStats();
+ private static final SysStats sysStats = SysStats.getSysStats();
public static SysStats getSysStats() {
return sysStats;
@@ -183,13 +181,13 @@ public class ParWork implements Closeable {
}
- private List<WorkUnit> workUnits = Collections.synchronizedList(new ArrayList<>());
+ private final List<WorkUnit> workUnits = Collections.synchronizedList(new ArrayList<>());
private volatile TimeTracker tracker;
private final boolean ignoreExceptions;
- private Set<Throwable> warns = ParWork.concSetSmallO();
+ private final Set<Throwable> warns = ParWork.concSetSmallO();
// TODO should take logger as well
public static class Exp extends Exception {
@@ -330,7 +328,6 @@ public class ParWork implements Closeable {
}
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
private void gatherObjects(Object object, List<ParObject> objects) {
if (object != null) {
if (object instanceof Collection) {
@@ -352,7 +349,7 @@ public class ParWork implements Closeable {
private void add(ParObject object) {
if (log.isDebugEnabled()) {
- log.debug("add(String label={}, Object object={}, Callable Callables={}) - start", object.label, object);
+ log.debug("add(String label={}, Object object={}) - start", object.label, object);
}
List<ParObject> objects;
if (object.object instanceof Collection) {
@@ -410,7 +407,7 @@ public class ParWork implements Closeable {
if (requireAnotherThread) {
closeCalls.add(new NoLimitsCallable<Object>() {
@Override
- public Object call() throws Exception {
+ public Object call() {
try {
handleObject(exception, finalWorkUnitTracker,
object);
diff --git a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
index 845df6c..f48d740 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class ParWorkExecutor extends ThreadPoolExecutor {
private static final Logger log = LoggerFactory
.getLogger(MethodHandles.lookup().lookupClass());
- public static final int KEEP_ALIVE_TIME = 15000;
+ public static final int KEEP_ALIVE_TIME = 30000;
private static AtomicInteger threadNumber = new AtomicInteger(0);
private volatile boolean closed;
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
index deb8025..08352f0 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
@@ -88,7 +88,7 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
}
public SolrQueuedThreadPool(String name) {
- this(10000, 15,
+ this(Integer.MAX_VALUE, 12,
60000, 0,
null, null,
new SolrNamedThreadFactory(name));
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java b/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
index 4ce3043..8262202 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
@@ -32,7 +32,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import org.apache.solr.common.NavigableObject;
import org.apache.solr.common.ParWork;
@@ -262,7 +261,7 @@ public class ValidatingJsonMap implements Map<String, Object>, NavigableObject {
try {
ValidatingJsonMap map = (ValidatingJsonMap) getObjectBuilder(
new JSONParser(r)).getObject();
- handleIncludes(map, includeLocation, 2); // nocommit
+ handleIncludes(map, includeLocation, 4);
return map;
} catch (IOException e) {
throw new RuntimeException();
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
index 7a8654d..0a014c8 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
@@ -537,8 +537,8 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
//the df=text here is a kluge for the test to supply a default field in case there is none in schema.xml
// alternatively, the resulting assertion could be modified to assert that no default field is specified.
- ex = expectThrows(SolrException.class, () -> client.deleteByQuery( "{!df=text} ??::?? ignore_exception" ));
- assertTrue(ex.getMessage().indexOf("??::?? ignore_exception")>0); // The reason should get passed through
+ Exception ex2 = expectThrows(Exception.class, () -> client.deleteByQuery( "{!df=text} ??::?? ignore_exception" ));
+ assertTrue(ex2.getMessage().indexOf("??::?? ignore_exception")>0); // The reason should get passed through
assertEquals(400, ex.code());
SolrInputDocument doc = new SolrInputDocument();
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
index 04beb5c..75a96f9 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
@@ -626,16 +626,6 @@ public class SolrTestCase extends LuceneTestCase {
public static SolrQueuedThreadPool getQtp() {
SolrQueuedThreadPool qtp = new SolrQueuedThreadPool("solr-test-qtp");;
- qtp.setName("solr-test-qtp");
- //qtp.setMaxThreads(Integer.getInteger("solr.maxContainerThreads", 50));
- // qtp.setLowThreadsThreshold(Integer.getInteger("solr.lowContainerThreadsThreshold", -1)); // we don't use this or connections will get cut
- qtp.setMinThreads(Integer.getInteger("solr.minContainerThreads", 8));
- qtp.setIdleTimeout(Integer.getInteger("solr.containerThreadsIdle", 45000));
-
- qtp.setStopTimeout((int) TimeUnit.SECONDS.toMillis(60));
- qtp.setDaemon(true);
- qtp.setReservedThreads(0);
- qtp.setStopTimeout(0);
return qtp;
}