mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 02:58:58 +00:00
SOLR-8750 : Use lambdas in code where SAM type interfaces are used
This commit is contained in:
parent
948a388778
commit
8d835f1231
@ -700,18 +700,15 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(expected,
|
Collections.sort(expected,
|
||||||
new Comparator<Input>() {
|
(a1, b) -> {
|
||||||
@Override
|
if (a1.v > b.v) {
|
||||||
public int compare(Input a, Input b) {
|
return -1;
|
||||||
if (a.v > b.v) {
|
} else if (a1.v < b.v) {
|
||||||
return -1;
|
return 1;
|
||||||
} else if (a.v < b.v) {
|
} else {
|
||||||
return 1;
|
return 0;
|
||||||
} else {
|
}
|
||||||
return 0;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (expected.isEmpty() == false) {
|
if (expected.isEmpty() == false) {
|
||||||
|
|
||||||
|
@ -99,14 +99,10 @@ public class Assign {
|
|||||||
map.put(shardId, cnt);
|
map.put(shardId, cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(shardIdNames, new Comparator<String>() {
|
Collections.sort(shardIdNames, (o1, o2) -> {
|
||||||
|
Integer one = map.get(o1);
|
||||||
@Override
|
Integer two = map.get(o2);
|
||||||
public int compare(String o1, String o2) {
|
return one.compareTo(two);
|
||||||
Integer one = map.get(o1);
|
|
||||||
Integer two = map.get(o2);
|
|
||||||
return one.compareTo(two);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
returnShardId = shardIdNames.get(0);
|
returnShardId = shardIdNames.get(0);
|
||||||
@ -179,12 +175,7 @@ public class Assign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<ReplicaCount> sortedNodeList = new ArrayList<>(nodeNameVsShardCount.values());
|
ArrayList<ReplicaCount> sortedNodeList = new ArrayList<>(nodeNameVsShardCount.values());
|
||||||
Collections.sort(sortedNodeList, new Comparator<ReplicaCount>() {
|
Collections.sort(sortedNodeList, (x, y) -> (x.weight() < y.weight()) ? -1 : ((x.weight() == y.weight()) ? 0 : 1));
|
||||||
@Override
|
|
||||||
public int compare(ReplicaCount x, ReplicaCount y) {
|
|
||||||
return (x.weight() < y.weight()) ? -1 : ((x.weight() == y.weight()) ? 0 : 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return sortedNodeList;
|
return sortedNodeList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -370,13 +370,9 @@ public class LeaderElector {
|
|||||||
* Sort n string sequence list.
|
* Sort n string sequence list.
|
||||||
*/
|
*/
|
||||||
public static void sortSeqs(List<String> seqs) {
|
public static void sortSeqs(List<String> seqs) {
|
||||||
Collections.sort(seqs, new Comparator<String>() {
|
Collections.sort(seqs, (o1, o2) -> {
|
||||||
|
int i = getSeq(o1) - getSeq(o2);
|
||||||
@Override
|
return i == 0 ? o1.compareTo(o2) : i;
|
||||||
public int compare(String o1, String o2) {
|
|
||||||
int i = getSeq(o1) - getSeq(o2);
|
|
||||||
return i == 0 ? o1.compareTo(o2) : i ;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,9 +181,7 @@ public class ZkCLI {
|
|||||||
SolrZkClient zkClient = null;
|
SolrZkClient zkClient = null;
|
||||||
try {
|
try {
|
||||||
zkClient = new SolrZkClient(zkServerAddress, 30000, 30000,
|
zkClient = new SolrZkClient(zkServerAddress, 30000, 30000,
|
||||||
new OnReconnect() {
|
() -> {
|
||||||
@Override
|
|
||||||
public void command() {}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (line.getOptionValue(CMD).equalsIgnoreCase(BOOTSTRAP)) {
|
if (line.getOptionValue(CMD).equalsIgnoreCase(BOOTSTRAP)) {
|
||||||
|
@ -358,11 +358,8 @@ public final class ZkController {
|
|||||||
this.overseerCompletedMap = Overseer.getCompletedMap(zkClient);
|
this.overseerCompletedMap = Overseer.getCompletedMap(zkClient);
|
||||||
this.overseerFailureMap = Overseer.getFailureMap(zkClient);
|
this.overseerFailureMap = Overseer.getFailureMap(zkClient);
|
||||||
cmdExecutor = new ZkCmdExecutor(clientTimeout);
|
cmdExecutor = new ZkCmdExecutor(clientTimeout);
|
||||||
zkStateReader = new ZkStateReader(zkClient, new Runnable() {
|
zkStateReader = new ZkStateReader(zkClient, () -> {
|
||||||
@Override
|
if (cc != null) cc.securityNodeChanged();
|
||||||
public void run() {
|
|
||||||
if(cc!=null) cc.securityNodeChanged();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.baseURL = zkStateReader.getBaseUrlForNodeName(this.nodeName);
|
this.baseURL = zkStateReader.getBaseUrlForNodeName(this.nodeName);
|
||||||
@ -2402,14 +2399,11 @@ public final class ZkController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OnReconnect getConfigDirListener() {
|
public OnReconnect getConfigDirListener() {
|
||||||
return new OnReconnect() {
|
return () -> {
|
||||||
@Override
|
synchronized (confDirectoryListeners) {
|
||||||
public void command() {
|
for (String s : confDirectoryListeners.keySet()) {
|
||||||
synchronized (confDirectoryListeners) {
|
setConfWatcher(s, new WatcherImpl(s), null);
|
||||||
for (String s : confDirectoryListeners.keySet()) {
|
fireEventListeners(s);
|
||||||
setConfWatcher(s, new WatcherImpl(s), null);
|
|
||||||
fireEventListeners(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -210,28 +210,25 @@ public class ReplicaAssigner {
|
|||||||
int startPosition = 0;
|
int startPosition = 0;
|
||||||
Map<String, Map<String, Integer>> copyOfCurrentState = getDeepCopy(shardVsNodes, 2);
|
Map<String, Map<String, Integer>> copyOfCurrentState = getDeepCopy(shardVsNodes, 2);
|
||||||
List<String> sortedLiveNodes = new ArrayList<>(this.participatingLiveNodes);
|
List<String> sortedLiveNodes = new ArrayList<>(this.participatingLiveNodes);
|
||||||
Collections.sort(sortedLiveNodes, new Comparator<String>() {
|
Collections.sort(sortedLiveNodes, (n1, n2) -> {
|
||||||
@Override
|
int result1 = 0;
|
||||||
public int compare(String n1, String n2) {
|
for (int i = 0; i < rulePermutation.length; i++) {
|
||||||
int result = 0;
|
Rule rule = rules.get(rulePermutation[i]);
|
||||||
for (int i = 0; i < rulePermutation.length; i++) {
|
int val = rule.compare(n1, n2, nodeVsTagsCopy, copyOfCurrentState);
|
||||||
Rule rule = rules.get(rulePermutation[i]);
|
if (val != 0) {//atleast one non-zero compare break now
|
||||||
int val = rule.compare(n1, n2, nodeVsTagsCopy, copyOfCurrentState);
|
result1 = val;
|
||||||
if (val != 0) {//atleast one non-zero compare break now
|
break;
|
||||||
result = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (result == 0) {//if all else is equal, prefer nodes with fewer cores
|
|
||||||
AtomicInteger n1Count = nodeVsCores.get(n1);
|
|
||||||
AtomicInteger n2Count = nodeVsCores.get(n2);
|
|
||||||
int a = n1Count == null ? 0 : n1Count.get();
|
|
||||||
int b = n2Count == null ? 0 : n2Count.get();
|
|
||||||
result = a > b ? 1 : a == b ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
if (result1 == 0) {//if all else is equal, prefer nodes with fewer cores
|
||||||
|
AtomicInteger n1Count = nodeVsCores.get(n1);
|
||||||
|
AtomicInteger n2Count = nodeVsCores.get(n2);
|
||||||
|
int a = n1Count == null ? 0 : n1Count.get();
|
||||||
|
int b = n2Count == null ? 0 : n2Count.get();
|
||||||
|
result1 = a > b ? 1 : a == b ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return result1;
|
||||||
});
|
});
|
||||||
forEachPosition:
|
forEachPosition:
|
||||||
for (Position position : positions) {
|
for (Position position : positions) {
|
||||||
|
@ -2530,46 +2530,43 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
|
|||||||
schemaRes = mis.getResourceName();
|
schemaRes = mis.getResourceName();
|
||||||
}
|
}
|
||||||
final String managedSchmaResourcePath = schemaRes == null ? null : zkSolrResourceLoader.getConfigSetZkPath() + "/" + schemaRes;
|
final String managedSchmaResourcePath = schemaRes == null ? null : zkSolrResourceLoader.getConfigSetZkPath() + "/" + schemaRes;
|
||||||
return new Runnable() {
|
return () -> {
|
||||||
@Override
|
log.info("config update listener called for core {}", coreName);
|
||||||
public void run() {
|
SolrZkClient zkClient = cc.getZkController().getZkClient();
|
||||||
log.info("config update listener called for core {}", coreName);
|
int solrConfigversion, overlayVersion, managedSchemaVersion = 0;
|
||||||
SolrZkClient zkClient = cc.getZkController().getZkClient();
|
SolrConfig cfg = null;
|
||||||
int solrConfigversion, overlayVersion, managedSchemaVersion = 0;
|
try (SolrCore core1 = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
||||||
SolrConfig cfg = null;
|
if (core1 == null || core1.isClosed()) return;
|
||||||
try (SolrCore core = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
cfg = core1.getSolrConfig();
|
||||||
if (core == null || core.isClosed()) return;
|
solrConfigversion = core1.getSolrConfig().getOverlay().getZnodeVersion();
|
||||||
cfg = core.getSolrConfig();
|
overlayVersion = core1.getSolrConfig().getZnodeVersion();
|
||||||
solrConfigversion = core.getSolrConfig().getOverlay().getZnodeVersion();
|
if (managedSchmaResourcePath != null) {
|
||||||
overlayVersion = core.getSolrConfig().getZnodeVersion();
|
managedSchemaVersion = ((ManagedIndexSchema) core1.getLatestSchema()).getSchemaZkVersion();
|
||||||
if (managedSchmaResourcePath != null) {
|
|
||||||
managedSchemaVersion = ((ManagedIndexSchema) core.getLatestSchema()).getSchemaZkVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (cfg != null) {
|
|
||||||
cfg.refreshRequestParams();
|
|
||||||
}
|
|
||||||
if (checkStale(zkClient, overlayPath, solrConfigversion) ||
|
|
||||||
checkStale(zkClient, solrConfigPath, overlayVersion) ||
|
|
||||||
checkStale(zkClient, managedSchmaResourcePath, managedSchemaVersion)) {
|
|
||||||
log.info("core reload {}", coreName);
|
|
||||||
cc.reload(coreName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//some files in conf directory may have other than managedschema, overlay, params
|
|
||||||
try (SolrCore core = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
|
||||||
if (core == null || core.isClosed()) return;
|
|
||||||
for (Runnable listener : core.confListeners) {
|
|
||||||
try {
|
|
||||||
listener.run();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error in listener ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (cfg != null) {
|
||||||
|
cfg.refreshRequestParams();
|
||||||
|
}
|
||||||
|
if (checkStale(zkClient, overlayPath, solrConfigversion) ||
|
||||||
|
checkStale(zkClient, solrConfigPath, overlayVersion) ||
|
||||||
|
checkStale(zkClient, managedSchmaResourcePath, managedSchemaVersion)) {
|
||||||
|
log.info("core reload {}", coreName);
|
||||||
|
cc.reload(coreName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//some files in conf directory may have other than managedschema, overlay, params
|
||||||
|
try (SolrCore core1 = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
||||||
|
if (core1 == null || core1.isClosed()) return;
|
||||||
|
for (Runnable listener : core1.confListeners) {
|
||||||
|
try {
|
||||||
|
listener.run();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error in listener ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,32 +68,27 @@ class CdcrReplicatorScheduler {
|
|||||||
|
|
||||||
// the scheduler thread is executed every second and submits one replication task
|
// the scheduler thread is executed every second and submits one replication task
|
||||||
// per available state in the queue
|
// per available state in the queue
|
||||||
scheduler.scheduleWithFixedDelay(new Runnable() {
|
scheduler.scheduleWithFixedDelay(() -> {
|
||||||
|
int nCandidates = statesQueue.size();
|
||||||
|
for (int i = 0; i < nCandidates; i++) {
|
||||||
|
// a thread that poll one state from the queue, execute the replication task, and push back
|
||||||
|
// the state in the queue when the task is completed
|
||||||
|
replicatorsPool.execute(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int nCandidates = statesQueue.size();
|
CdcrReplicatorState state = statesQueue.poll();
|
||||||
for (int i = 0; i < nCandidates; i++) {
|
assert state != null; // Should never happen
|
||||||
// a thread that poll one state from the queue, execute the replication task, and push back
|
try {
|
||||||
// the state in the queue when the task is completed
|
new CdcrReplicator(state, batchSize).run();
|
||||||
replicatorsPool.execute(new Runnable() {
|
} finally {
|
||||||
|
statesQueue.offer(state);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
CdcrReplicatorState state = statesQueue.poll();
|
|
||||||
assert state != null; // Should never happen
|
|
||||||
try {
|
|
||||||
new CdcrReplicator(state, batchSize).run();
|
|
||||||
} finally {
|
|
||||||
statesQueue.offer(state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 0, timeSchedule, TimeUnit.MILLISECONDS);
|
}, 0, timeSchedule, TimeUnit.MILLISECONDS);
|
||||||
isStarted = true;
|
isStarted = true;
|
||||||
}
|
}
|
||||||
|
@ -1452,14 +1452,11 @@ public class IndexFetcher {
|
|||||||
} finally {
|
} finally {
|
||||||
cleanup();
|
cleanup();
|
||||||
//if cleanup succeeds . The file is downloaded fully. do an fsync
|
//if cleanup succeeds . The file is downloaded fully. do an fsync
|
||||||
fsyncService.submit(new Runnable(){
|
fsyncService.submit(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
file.sync();
|
||||||
try {
|
} catch (IOException e) {
|
||||||
file.sync();
|
fsyncException = e;
|
||||||
} catch (IOException e) {
|
|
||||||
fsyncException = e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1077,20 +1077,17 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable task = new Runnable() {
|
Runnable task = () -> {
|
||||||
@Override
|
if (pollDisabled.get()) {
|
||||||
public void run() {
|
LOG.info("Poll disabled");
|
||||||
if (pollDisabled.get()) {
|
return;
|
||||||
LOG.info("Poll disabled");
|
}
|
||||||
return;
|
try {
|
||||||
}
|
LOG.debug("Polling for index modifications");
|
||||||
try {
|
markScheduledExecutionStart();
|
||||||
LOG.debug("Polling for index modifications");
|
doFetch(null, false);
|
||||||
markScheduledExecutionStart();
|
} catch (Exception e) {
|
||||||
doFetch(null, false);
|
LOG.error("Exception in fetching index", e);
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("Exception in fetching index", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
executorService = Executors.newSingleThreadScheduledExecutor(
|
executorService = Executors.newSingleThreadScheduledExecutor(
|
||||||
|
@ -155,23 +155,20 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||||||
try {
|
try {
|
||||||
MDC.put("CoreAdminHandler.asyncId", taskId);
|
MDC.put("CoreAdminHandler.asyncId", taskId);
|
||||||
MDC.put("CoreAdminHandler.action", op.action.toString());
|
MDC.put("CoreAdminHandler.action", op.action.toString());
|
||||||
parallelExecutor.execute(new Runnable() {
|
parallelExecutor.execute(() -> {
|
||||||
@Override
|
boolean exceptionCaught = false;
|
||||||
public void run() {
|
try {
|
||||||
boolean exceptionCaught = false;
|
callInfo.call();
|
||||||
try {
|
taskObject.setRspObject(callInfo.rsp);
|
||||||
callInfo.call();
|
} catch (Exception e) {
|
||||||
taskObject.setRspObject(callInfo.rsp);
|
exceptionCaught = true;
|
||||||
} catch (Exception e) {
|
taskObject.setRspObjectFromException(e);
|
||||||
exceptionCaught = true;
|
} finally {
|
||||||
taskObject.setRspObjectFromException(e);
|
removeTask("running", taskObject.taskId);
|
||||||
} finally {
|
if (exceptionCaught) {
|
||||||
removeTask("running", taskObject.taskId);
|
addTask("failed", taskObject, true);
|
||||||
if (exceptionCaught) {
|
} else
|
||||||
addTask("failed", taskObject, true);
|
addTask("completed", taskObject, true);
|
||||||
} else
|
|
||||||
addTask("completed", taskObject, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1448,12 +1448,7 @@ public class FacetComponent extends SearchComponent {
|
|||||||
public ShardFacetCount[] getLexSorted() {
|
public ShardFacetCount[] getLexSorted() {
|
||||||
ShardFacetCount[] arr
|
ShardFacetCount[] arr
|
||||||
= counts.values().toArray(new ShardFacetCount[counts.size()]);
|
= counts.values().toArray(new ShardFacetCount[counts.size()]);
|
||||||
Arrays.sort(arr, new Comparator<ShardFacetCount>() {
|
Arrays.sort(arr, (o1, o2) -> o1.indexed.compareTo(o2.indexed));
|
||||||
@Override
|
|
||||||
public int compare(ShardFacetCount o1, ShardFacetCount o2) {
|
|
||||||
return o1.indexed.compareTo(o2.indexed);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
countSorted = arr;
|
countSorted = arr;
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@ -1461,13 +1456,10 @@ public class FacetComponent extends SearchComponent {
|
|||||||
public ShardFacetCount[] getCountSorted() {
|
public ShardFacetCount[] getCountSorted() {
|
||||||
ShardFacetCount[] arr
|
ShardFacetCount[] arr
|
||||||
= counts.values().toArray(new ShardFacetCount[counts.size()]);
|
= counts.values().toArray(new ShardFacetCount[counts.size()]);
|
||||||
Arrays.sort(arr, new Comparator<ShardFacetCount>() {
|
Arrays.sort(arr, (o1, o2) -> {
|
||||||
@Override
|
if (o2.count < o1.count) return -1;
|
||||||
public int compare(ShardFacetCount o1, ShardFacetCount o2) {
|
else if (o1.count < o2.count) return 1;
|
||||||
if (o2.count < o1.count) return -1;
|
return o1.indexed.compareTo(o2.indexed);
|
||||||
else if (o1.count < o2.count) return 1;
|
|
||||||
return o1.indexed.compareTo(o2.indexed);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
countSorted = arr;
|
countSorted = arr;
|
||||||
return arr;
|
return arr;
|
||||||
|
@ -66,12 +66,10 @@ public interface MergeStrategy {
|
|||||||
* */
|
* */
|
||||||
public int getCost();
|
public int getCost();
|
||||||
|
|
||||||
public static final Comparator MERGE_COMP = new Comparator() {
|
final Comparator MERGE_COMP = (o1, o2) -> {
|
||||||
public int compare(Object o1, Object o2) {
|
MergeStrategy m1 = (MergeStrategy) o1;
|
||||||
MergeStrategy m1 = (MergeStrategy)o1;
|
MergeStrategy m2 = (MergeStrategy) o2;
|
||||||
MergeStrategy m2 = (MergeStrategy)o2;
|
return m1.getCost() - m2.getCost();
|
||||||
return m1.getCost()-m2.getCost();
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
@ -104,7 +104,15 @@ public class ShardFieldSortedHitQueue extends PriorityQueue<ShardDoc> {
|
|||||||
Comparator<ShardDoc> getCachedComparator(SortField sortField, IndexSearcher searcher) {
|
Comparator<ShardDoc> getCachedComparator(SortField sortField, IndexSearcher searcher) {
|
||||||
SortField.Type type = sortField.getType();
|
SortField.Type type = sortField.getType();
|
||||||
if (type == SortField.Type.SCORE) {
|
if (type == SortField.Type.SCORE) {
|
||||||
return comparatorScore();
|
return (o1, o2) -> {
|
||||||
|
final float f1 = o1.score;
|
||||||
|
final float f2 = o2.score;
|
||||||
|
if (f1 < f2)
|
||||||
|
return -1;
|
||||||
|
if (f1 > f2)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
} else if (type == SortField.Type.REWRITEABLE) {
|
} else if (type == SortField.Type.REWRITEABLE) {
|
||||||
try {
|
try {
|
||||||
sortField = sortField.rewrite(searcher);
|
sortField = sortField.rewrite(searcher);
|
||||||
@ -140,21 +148,6 @@ public class ShardFieldSortedHitQueue extends PriorityQueue<ShardDoc> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Comparator<ShardDoc> comparatorScore() {
|
|
||||||
return new Comparator<ShardDoc>() {
|
|
||||||
@Override
|
|
||||||
public final int compare(final ShardDoc o1, final ShardDoc o2) {
|
|
||||||
final float f1 = o1.score;
|
|
||||||
final float f2 = o2.score;
|
|
||||||
if (f1 < f2)
|
|
||||||
return -1;
|
|
||||||
if (f1 > f2)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Comparator<ShardDoc> comparatorFieldComparator(SortField sortField) {
|
Comparator<ShardDoc> comparatorFieldComparator(SortField sortField) {
|
||||||
final FieldComparator fieldComparator;
|
final FieldComparator fieldComparator;
|
||||||
try {
|
try {
|
||||||
|
@ -441,12 +441,7 @@ public class TermsComponent extends SearchComponent {
|
|||||||
public TermsResponse.Term[] getLexSorted(HashMap<String, TermsResponse.Term> data) {
|
public TermsResponse.Term[] getLexSorted(HashMap<String, TermsResponse.Term> data) {
|
||||||
TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
|
TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
|
||||||
|
|
||||||
Arrays.sort(arr, new Comparator<TermsResponse.Term>() {
|
Arrays.sort(arr, (o1, o2) -> o1.getTerm().compareTo(o2.getTerm()));
|
||||||
@Override
|
|
||||||
public int compare(TermsResponse.Term o1, TermsResponse.Term o2) {
|
|
||||||
return o1.getTerm().compareTo(o2.getTerm());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@ -455,19 +450,16 @@ public class TermsComponent extends SearchComponent {
|
|||||||
public TermsResponse.Term[] getCountSorted(HashMap<String, TermsResponse.Term> data) {
|
public TermsResponse.Term[] getCountSorted(HashMap<String, TermsResponse.Term> data) {
|
||||||
TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
|
TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
|
||||||
|
|
||||||
Arrays.sort(arr, new Comparator<TermsResponse.Term>() {
|
Arrays.sort(arr, (o1, o2) -> {
|
||||||
@Override
|
long freq1 = o1.getFrequency();
|
||||||
public int compare(TermsResponse.Term o1, TermsResponse.Term o2) {
|
long freq2 = o2.getFrequency();
|
||||||
long freq1 = o1.getFrequency();
|
|
||||||
long freq2 = o2.getFrequency();
|
if (freq2 < freq1) {
|
||||||
|
return -1;
|
||||||
if (freq2 < freq1) {
|
} else if (freq1 < freq2) {
|
||||||
return -1;
|
return 1;
|
||||||
} else if (freq1 < freq2) {
|
} else {
|
||||||
return 1;
|
return o1.getTerm().compareTo(o2.getTerm());
|
||||||
} else {
|
|
||||||
return o1.getTerm().compareTo(o2.getTerm());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -613,12 +613,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
|
|||||||
if (frags.size() > 0) {
|
if (frags.size() > 0) {
|
||||||
// sort such that the fragments with the highest score come first
|
// sort such that the fragments with the highest score come first
|
||||||
if (!preserveMulti) {
|
if (!preserveMulti) {
|
||||||
Collections.sort(frags, new Comparator<TextFragment>() {//TODO make TextFragment Comparable
|
Collections.sort(frags, (arg0, arg1) -> Float.compare(arg1.getScore(), arg0.getScore()));
|
||||||
@Override
|
|
||||||
public int compare(TextFragment arg0, TextFragment arg1) {
|
|
||||||
return Float.compare(arg1.getScore(), arg0.getScore());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate list to hl.snippets, but not when hl.preserveMulti
|
// Truncate list to hl.snippets, but not when hl.preserveMulti
|
||||||
|
@ -1410,12 +1410,9 @@ public class IndexSchema {
|
|||||||
SortedMap<String,List<CopyField>> sortedCopyFields = new TreeMap<>(copyFieldsMap);
|
SortedMap<String,List<CopyField>> sortedCopyFields = new TreeMap<>(copyFieldsMap);
|
||||||
for (List<CopyField> copyFields : sortedCopyFields.values()) {
|
for (List<CopyField> copyFields : sortedCopyFields.values()) {
|
||||||
copyFields = new ArrayList<>(copyFields);
|
copyFields = new ArrayList<>(copyFields);
|
||||||
Collections.sort(copyFields, new Comparator<CopyField>() {
|
Collections.sort(copyFields, (cf1, cf2) -> {
|
||||||
@Override
|
// sources are all the same, just sorting by destination here
|
||||||
public int compare(CopyField cf1, CopyField cf2) {
|
return cf1.getDestination().getName().compareTo(cf2.getDestination().getName());
|
||||||
// sources are all the same, just sorting by destination here
|
|
||||||
return cf1.getDestination().getName().compareTo(cf2.getDestination().getName());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
for (CopyField copyField : copyFields) {
|
for (CopyField copyField : copyFields) {
|
||||||
final String source = copyField.getSource().getName();
|
final String source = copyField.getSource().getName();
|
||||||
|
@ -1068,12 +1068,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
|
|||||||
public boolean hasDeletedDocs; // true if it's possible that filter may match deleted docs
|
public boolean hasDeletedDocs; // true if it's possible that filter may match deleted docs
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Comparator<Query> sortByCost = new Comparator<Query>() {
|
private static Comparator<Query> sortByCost = (q1, q2) -> ((ExtendedQuery) q1).getCost() - ((ExtendedQuery) q2).getCost();
|
||||||
@Override
|
|
||||||
public int compare(Query q1, Query q2) {
|
|
||||||
return ((ExtendedQuery) q1).getCost() - ((ExtendedQuery) q2).getCost();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private DocSet getDocSetScore(List<Query> queries) throws IOException {
|
private DocSet getDocSetScore(List<Query> queries) throws IOException {
|
||||||
Query main = queries.remove(0);
|
Query main = queries.remove(0);
|
||||||
|
@ -532,21 +532,13 @@ class FacetFieldMerger extends FacetBucketMerger<FacetField> {
|
|||||||
final int sortMul = direction.getMultiplier();
|
final int sortMul = direction.getMultiplier();
|
||||||
|
|
||||||
if ("count".equals(freq.sortVariable)) {
|
if ("count".equals(freq.sortVariable)) {
|
||||||
comparator = new Comparator<FacetBucket>() {
|
comparator = (o1, o2) -> {
|
||||||
@Override
|
int v = -Long.compare(o1.count, o2.count) * sortMul;
|
||||||
public int compare(FacetBucket o1, FacetBucket o2) {
|
return v == 0 ? o1.bucketValue.compareTo(o2.bucketValue) : v;
|
||||||
int v = -Long.compare(o1.count, o2.count) * sortMul;
|
|
||||||
return v == 0 ? o1.bucketValue.compareTo(o2.bucketValue) : v;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Collections.sort(sortedBuckets, comparator);
|
Collections.sort(sortedBuckets, comparator);
|
||||||
} else if ("index".equals(freq.sortVariable)) {
|
} else if ("index".equals(freq.sortVariable)) {
|
||||||
comparator = new Comparator<FacetBucket>() {
|
comparator = (o1, o2) -> -o1.bucketValue.compareTo(o2.bucketValue) * sortMul;
|
||||||
@Override
|
|
||||||
public int compare(FacetBucket o1, FacetBucket o2) {
|
|
||||||
return -o1.bucketValue.compareTo(o2.bucketValue) * sortMul;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Collections.sort(sortedBuckets, comparator);
|
Collections.sort(sortedBuckets, comparator);
|
||||||
} else {
|
} else {
|
||||||
final String key = freq.sortVariable;
|
final String key = freq.sortVariable;
|
||||||
@ -598,12 +590,7 @@ class FacetFieldMerger extends FacetBucketMerger<FacetField> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(lst);
|
Collections.sort(lst);
|
||||||
Collections.sort(nulls, new Comparator<FacetBucket>() {
|
Collections.sort(nulls, (o1, o2) -> o1.bucketValue.compareTo(o2.bucketValue));
|
||||||
@Override
|
|
||||||
public int compare(FacetBucket o1, FacetBucket o2) {
|
|
||||||
return o1.bucketValue.compareTo(o2.bucketValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ArrayList<FacetBucket> out = new ArrayList<>(buckets.size());
|
ArrayList<FacetBucket> out = new ArrayList<>(buckets.size());
|
||||||
for (SortVal sv : lst) {
|
for (SortVal sv : lst) {
|
||||||
|
@ -86,34 +86,28 @@ public class PeerSync {
|
|||||||
private SolrCore core;
|
private SolrCore core;
|
||||||
|
|
||||||
// comparator that sorts by absolute value, putting highest first
|
// comparator that sorts by absolute value, putting highest first
|
||||||
private static Comparator<Long> absComparator = new Comparator<Long>() {
|
private static Comparator<Long> absComparator = (o1, o2) -> {
|
||||||
@Override
|
long l1 = Math.abs(o1);
|
||||||
public int compare(Long o1, Long o2) {
|
long l2 = Math.abs(o2);
|
||||||
long l1 = Math.abs(o1);
|
if (l1 > l2) return -1;
|
||||||
long l2 = Math.abs(o2);
|
if (l1 < l2) return 1;
|
||||||
if (l1 >l2) return -1;
|
return 0;
|
||||||
if (l1 < l2) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// comparator that sorts update records by absolute value of version, putting lowest first
|
// comparator that sorts update records by absolute value of version, putting lowest first
|
||||||
private static Comparator<Object> updateRecordComparator = new Comparator<Object>() {
|
private static Comparator<Object> updateRecordComparator = (o1, o2) -> {
|
||||||
@Override
|
if (!(o1 instanceof List)) return 1;
|
||||||
public int compare(Object o1, Object o2) {
|
if (!(o2 instanceof List)) return -1;
|
||||||
if (!(o1 instanceof List)) return 1;
|
|
||||||
if (!(o2 instanceof List)) return -1;
|
|
||||||
|
|
||||||
List lst1 = (List)o1;
|
List lst1 = (List) o1;
|
||||||
List lst2 = (List)o2;
|
List lst2 = (List) o2;
|
||||||
|
|
||||||
long l1 = Math.abs((Long)lst1.get(1));
|
long l1 = Math.abs((Long) lst1.get(1));
|
||||||
long l2 = Math.abs((Long)lst2.get(1));
|
long l2 = Math.abs((Long) lst2.get(1));
|
||||||
|
|
||||||
if (l1 >l2) return 1;
|
if (l1 > l2) return 1;
|
||||||
if (l1 < l2) return -1;
|
if (l1 < l2) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -500,11 +500,7 @@ public final class DocExpirationUpdateProcessorFactory
|
|||||||
/** @see #iAmInChargeOfPeriodicDeletes */
|
/** @see #iAmInChargeOfPeriodicDeletes */
|
||||||
private volatile boolean previouslyInChargeOfDeletes = true;
|
private volatile boolean previouslyInChargeOfDeletes = true;
|
||||||
|
|
||||||
private static final Comparator<Slice> COMPARE_SLICES_BY_NAME = new Comparator<Slice>() {
|
private static final Comparator<Slice> COMPARE_SLICES_BY_NAME = (a, b) -> a.getName().compareTo(b.getName());
|
||||||
public int compare(Slice a, Slice b) {
|
|
||||||
return a.getName().compareTo(b.getName());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,13 +208,7 @@ public class DistributedIntervalFacetingTest extends
|
|||||||
values[0] = random().nextInt(max);
|
values[0] = random().nextInt(max);
|
||||||
values[1] = random().nextInt(max);
|
values[1] = random().nextInt(max);
|
||||||
if ("test_s_dv".equals(fieldName) || "test_ss_dv".equals(fieldName)) {
|
if ("test_s_dv".equals(fieldName) || "test_ss_dv".equals(fieldName)) {
|
||||||
Arrays.sort(values, new Comparator<Integer>() {
|
Arrays.sort(values, (o1, o2) -> String.valueOf(o1).compareTo(String.valueOf(o2)));
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Integer o1, Integer o2) {
|
|
||||||
return String.valueOf(o1).compareTo(String.valueOf(o2));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
Arrays.sort(values);
|
Arrays.sort(values);
|
||||||
}
|
}
|
||||||
|
@ -915,26 +915,20 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
|
|||||||
|
|
||||||
|
|
||||||
public static Comparator<Grp> createMaxDocComparator(final Comparator<Doc> docComparator) {
|
public static Comparator<Grp> createMaxDocComparator(final Comparator<Doc> docComparator) {
|
||||||
return new Comparator<Grp>() {
|
return (o1, o2) -> {
|
||||||
@Override
|
// all groups should have at least one doc
|
||||||
public int compare(Grp o1, Grp o2) {
|
Doc d1 = o1.maxDoc;
|
||||||
// all groups should have at least one doc
|
Doc d2 = o2.maxDoc;
|
||||||
Doc d1 = o1.maxDoc;
|
return docComparator.compare(d1, d2);
|
||||||
Doc d2 = o2.maxDoc;
|
|
||||||
return docComparator.compare(d1, d2);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Comparator<Grp> createFirstDocComparator(final Comparator<Doc> docComparator) {
|
public static Comparator<Grp> createFirstDocComparator(final Comparator<Doc> docComparator) {
|
||||||
return new Comparator<Grp>() {
|
return (o1, o2) -> {
|
||||||
@Override
|
// all groups should have at least one doc
|
||||||
public int compare(Grp o1, Grp o2) {
|
Doc d1 = o1.docs.get(0);
|
||||||
// all groups should have at least one doc
|
Doc d2 = o2.docs.get(0);
|
||||||
Doc d1 = o1.docs.get(0);
|
return docComparator.compare(d1, d2);
|
||||||
Doc d2 = o2.docs.get(0);
|
|
||||||
return docComparator.compare(d1, d2);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,25 +568,20 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||||||
ThreadPoolExecutor executor, final String collection, final int numShards, int cnt) {
|
ThreadPoolExecutor executor, final String collection, final int numShards, int cnt) {
|
||||||
for (int i = 0; i < cnt; i++) {
|
for (int i = 0; i < cnt; i++) {
|
||||||
final int freezeI = i;
|
final int freezeI = i;
|
||||||
executor.execute(new Runnable() {
|
executor.execute(() -> {
|
||||||
|
Create createCmd = new Create();
|
||||||
@Override
|
createCmd.setCoreName(collection + freezeI);
|
||||||
public void run() {
|
createCmd.setCollection(collection);
|
||||||
Create createCmd = new Create();
|
|
||||||
createCmd.setCoreName(collection + freezeI);
|
|
||||||
createCmd.setCollection(collection);
|
|
||||||
|
|
||||||
createCmd.setNumShards(numShards);
|
createCmd.setNumShards(numShards);
|
||||||
try {
|
try {
|
||||||
String core3dataDir = createTempDir(collection).toFile().getAbsolutePath();
|
String core3dataDir = createTempDir(collection).toFile().getAbsolutePath();
|
||||||
createCmd.setDataDir(getDataDir(core3dataDir));
|
createCmd.setDataDir(getDataDir(core3dataDir));
|
||||||
|
|
||||||
client.request(createCmd);
|
client.request(createCmd);
|
||||||
} catch (SolrServerException | IOException e) {
|
} catch (SolrServerException | IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,13 +145,10 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
|
|||||||
|
|
||||||
this.es = es;
|
this.es = es;
|
||||||
if (this.es == null) {
|
if (this.es == null) {
|
||||||
this.es = new ElectorSetup(new OnReconnect() {
|
this.es = new ElectorSetup(() -> {
|
||||||
@Override
|
try {
|
||||||
public void command() {
|
setupOnConnect();
|
||||||
try {
|
} catch (Throwable t) {
|
||||||
setupOnConnect();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -413,22 +413,18 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
|||||||
//register total of coreCount cores
|
//register total of coreCount cores
|
||||||
for (int i = 0; i < coreCount; i++) {
|
for (int i = 0; i < coreCount; i++) {
|
||||||
final int slot = i;
|
final int slot = i;
|
||||||
Runnable coreStarter = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
final String coreName = "core" + slot;
|
nodeExecutors[i % nodeCount].submit((Runnable) () -> {
|
||||||
|
|
||||||
try {
|
final String coreName = "core" + slot;
|
||||||
ids[slot]=controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, Replica.State.ACTIVE, sliceCount);
|
|
||||||
} catch (Throwable e) {
|
try {
|
||||||
e.printStackTrace();
|
ids[slot] = controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, Replica.State.ACTIVE, sliceCount);
|
||||||
fail("register threw exception:" + e.getClass());
|
} catch (Throwable e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
fail("register threw exception:" + e.getClass());
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
nodeExecutors[i % nodeCount].submit(coreStarter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nodeCount; i++) {
|
for (int i = 0; i < nodeCount; i++) {
|
||||||
|
@ -108,12 +108,10 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// force a deterministic random ordering of the files so seeds reproduce regardless of platform/filesystem
|
// force a deterministic random ordering of the files so seeds reproduce regardless of platform/filesystem
|
||||||
Collections.sort(xmlFiles, new Comparator<File>() {
|
Collections.sort(xmlFiles, (o1, o2) -> {
|
||||||
public int compare(File o1, File o2) {
|
// don't rely on File.compareTo, it's behavior varies by OS
|
||||||
// don't rely on File.compareTo, it's behavior varies by OS
|
return o1.getName().compareTo(o2.getName());
|
||||||
return o1.getName().compareTo(o2.getName());
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
Collections.shuffle(xmlFiles, new Random(random().nextLong()));
|
Collections.shuffle(xmlFiles, new Random(random().nextLong()));
|
||||||
|
|
||||||
// if you add/remove example XML docs, you'll have to fix these expected values
|
// if you add/remove example XML docs, you'll have to fix these expected values
|
||||||
|
@ -407,16 +407,13 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
|
|||||||
try {
|
try {
|
||||||
for (int j = 0; j < cnt; j++) {
|
for (int j = 0; j < cnt; j++) {
|
||||||
final int freezeJ = j;
|
final int freezeJ = j;
|
||||||
executor.execute(new Runnable() {
|
executor.execute(() -> {
|
||||||
@Override
|
Unload unloadCmd = new Unload(true);
|
||||||
public void run() {
|
unloadCmd.setCoreName("multiunload" + freezeJ);
|
||||||
Unload unloadCmd = new Unload(true);
|
try {
|
||||||
unloadCmd.setCoreName("multiunload" + freezeJ);
|
adminClient.request(unloadCmd);
|
||||||
try {
|
} catch (SolrServerException | IOException e) {
|
||||||
adminClient.request(unloadCmd);
|
throw new RuntimeException(e);
|
||||||
} catch (SolrServerException | IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Thread.sleep(random().nextInt(50));
|
Thread.sleep(random().nextInt(50));
|
||||||
|
@ -351,13 +351,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||||||
values[0] = random().nextInt(max);
|
values[0] = random().nextInt(max);
|
||||||
values[1] = random().nextInt(max);
|
values[1] = random().nextInt(max);
|
||||||
if (fieldName.startsWith("test_s")) {
|
if (fieldName.startsWith("test_s")) {
|
||||||
Arrays.sort(values, new Comparator<Integer>() {
|
Arrays.sort(values, (o1, o2) -> String.valueOf(o1).compareTo(String.valueOf(o2)));
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Integer o1, Integer o2) {
|
|
||||||
return String.valueOf(o1).compareTo(String.valueOf(o2));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
Arrays.sort(values);
|
Arrays.sort(values);
|
||||||
}
|
}
|
||||||
|
@ -385,14 +385,11 @@ public class TestLFUCache extends SolrTestCaseJ4 {
|
|||||||
* design, the cache eviction doesn't work right.
|
* design, the cache eviction doesn't work right.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < atLeast(2_000_000); ++i) {
|
for (int i = 0; i < atLeast(2_000_000); ++i) {
|
||||||
executorService.submit(new Runnable() {
|
executorService.submit(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
cache.put(random().nextInt(100), random().nextLong());
|
||||||
try {
|
} catch (Throwable t) {
|
||||||
cache.put(random().nextInt(100), random().nextLong());
|
error.compareAndSet(null, t);
|
||||||
} catch (Throwable t) {
|
|
||||||
error.compareAndSet(null, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -270,16 +270,13 @@ public class TestRankQueryPlugin extends QParserPlugin {
|
|||||||
} // end for-each-doc-in-response
|
} // end for-each-doc-in-response
|
||||||
} // end for-each-response
|
} // end for-each-response
|
||||||
|
|
||||||
Collections.sort(shardDocs, new Comparator<ShardDoc>() {
|
Collections.sort(shardDocs, (o1, o2) -> {
|
||||||
@Override
|
if (o1.score < o2.score) {
|
||||||
public int compare(ShardDoc o1, ShardDoc o2) {
|
return 1;
|
||||||
if(o1.score < o2.score) {
|
} else if (o1.score > o2.score) {
|
||||||
return 1;
|
return -1;
|
||||||
} else if (o1.score > o2.score) {
|
} else {
|
||||||
return -1;
|
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
} else {
|
|
||||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -591,16 +588,13 @@ public class TestRankQueryPlugin extends QParserPlugin {
|
|||||||
} // end for-each-doc-in-response
|
} // end for-each-doc-in-response
|
||||||
} // end for-each-response
|
} // end for-each-response
|
||||||
|
|
||||||
Collections.sort(shardDocs, new Comparator<ShardDoc>() {
|
Collections.sort(shardDocs, (o1, o2) -> {
|
||||||
@Override
|
if (o1.score < o2.score) {
|
||||||
public int compare(ShardDoc o1, ShardDoc o2) {
|
return 1;
|
||||||
if(o1.score < o2.score) {
|
} else if (o1.score > o2.score) {
|
||||||
return 1;
|
return -1;
|
||||||
} else if (o1.score > o2.score) {
|
} else {
|
||||||
return -1;
|
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
} else {
|
|
||||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,23 +93,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
clearIndex();
|
clearIndex();
|
||||||
@ -197,14 +189,11 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -359,23 +348,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -495,23 +476,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -632,12 +605,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
DirectUpdateHandler2.commitOnClose = false;
|
DirectUpdateHandler2.commitOnClose = false;
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -762,23 +730,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -827,23 +787,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
clearIndex();
|
clearIndex();
|
||||||
@ -959,23 +911,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
|
UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
|
||||||
File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());
|
File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());
|
||||||
@ -1098,23 +1042,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
|
UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
|
||||||
File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());
|
File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());
|
||||||
|
@ -153,23 +153,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
clearIndex();
|
clearIndex();
|
||||||
@ -257,23 +249,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -420,23 +404,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -556,12 +532,7 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
DirectUpdateHandler2.commitOnClose = false;
|
DirectUpdateHandler2.commitOnClose = false;
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -686,23 +657,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SolrQueryRequest req = req();
|
SolrQueryRequest req = req();
|
||||||
@ -751,14 +714,11 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -867,23 +827,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
|
String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
|
||||||
|
|
||||||
@ -1006,23 +958,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
|
String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
|
||||||
|
|
||||||
|
@ -299,25 +299,22 @@ public class TestSort extends SolrTestCaseJ4 {
|
|||||||
|
|
||||||
searcher.search(filt, myCollector);
|
searcher.search(filt, myCollector);
|
||||||
|
|
||||||
Collections.sort(collectedDocs, new Comparator<MyDoc>() {
|
Collections.sort(collectedDocs, (o1, o2) -> {
|
||||||
@Override
|
String v1 = o1.val == null ? nullRep : o1.val;
|
||||||
public int compare(MyDoc o1, MyDoc o2) {
|
String v2 = o2.val == null ? nullRep : o2.val;
|
||||||
String v1 = o1.val==null ? nullRep : o1.val;
|
int cmp = v1.compareTo(v2);
|
||||||
String v2 = o2.val==null ? nullRep : o2.val;
|
if (reverse) cmp = -cmp;
|
||||||
int cmp = v1.compareTo(v2);
|
if (cmp != 0) return cmp;
|
||||||
if (reverse) cmp = -cmp;
|
|
||||||
if (cmp != 0) return cmp;
|
|
||||||
|
|
||||||
if (secondary) {
|
if (secondary) {
|
||||||
v1 = o1.val2==null ? nullRep2 : o1.val2;
|
v1 = o1.val2 == null ? nullRep2 : o1.val2;
|
||||||
v2 = o2.val2==null ? nullRep2 : o2.val2;
|
v2 = o2.val2 == null ? nullRep2 : o2.val2;
|
||||||
cmp = v1.compareTo(v2);
|
cmp = v1.compareTo(v2);
|
||||||
if (reverse2) cmp = -cmp;
|
if (reverse2) cmp = -cmp;
|
||||||
}
|
|
||||||
|
|
||||||
cmp = cmp==0 ? o1.doc-o2.doc : cmp;
|
|
||||||
return cmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmp = cmp == 0 ? o1.doc - o2.doc : cmp;
|
||||||
|
return cmp;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,12 +148,9 @@ public class TestJsonFacets extends SolrTestCaseHS {
|
|||||||
for (int i=0; i<honda_model_counts.length-1; i++) {
|
for (int i=0; i<honda_model_counts.length-1; i++) {
|
||||||
idx.add(i);
|
idx.add(i);
|
||||||
}
|
}
|
||||||
Collections.sort(idx, new Comparator<Integer>() {
|
Collections.sort(idx, (o1, o2) -> {
|
||||||
@Override
|
int cmp = honda_model_counts[o2] - honda_model_counts[o1];
|
||||||
public int compare(Integer o1, Integer o2) {
|
return cmp == 0 ? o1 - o2 : cmp;
|
||||||
int cmp = honda_model_counts[o2] - honda_model_counts[o1];
|
|
||||||
return cmp == 0 ? o1 - o2 : cmp;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,12 +175,9 @@ public class TestScoreJoinQPScore extends SolrTestCaseJ4 {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final static Comparator<String> lessFloat = new Comparator<String>() {
|
final static Comparator<String> lessFloat = (o1, o2) -> {
|
||||||
@Override
|
assertTrue(Float.parseFloat(o1) < Float.parseFloat(o2));
|
||||||
public int compare(String o1, String o2) {
|
return 0;
|
||||||
assertTrue(Float.parseFloat(o1) < Float.parseFloat(o2));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Ignore("SOLR-7814, also don't forget cover boost at testCacheHit()")
|
@Ignore("SOLR-7814, also don't forget cover boost at testCacheHit()")
|
||||||
|
@ -436,23 +436,15 @@ public class CdcrUpdateLogTest extends SolrTestCaseJ4 {
|
|||||||
final Semaphore logReplay = new Semaphore(0);
|
final Semaphore logReplay = new Semaphore(0);
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
|
|
||||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
UpdateLog.testing_logReplayHook = () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||||
try {
|
} catch (Exception e) {
|
||||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
throw new RuntimeException(e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Deque<Long> versions = new ArrayDeque<>();
|
Deque<Long> versions = new ArrayDeque<>();
|
||||||
versions.addFirst(addAndGetVersion(sdoc("id", "A11"), null));
|
versions.addFirst(addAndGetVersion(sdoc("id", "A11"), null));
|
||||||
@ -668,12 +660,7 @@ public class CdcrUpdateLogTest extends SolrTestCaseJ4 {
|
|||||||
try {
|
try {
|
||||||
DirectUpdateHandler2.commitOnClose = false;
|
DirectUpdateHandler2.commitOnClose = false;
|
||||||
final Semaphore logReplayFinish = new Semaphore(0);
|
final Semaphore logReplayFinish = new Semaphore(0);
|
||||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logReplayFinish.release();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.clearCore();
|
this.clearCore();
|
||||||
|
|
||||||
|
@ -398,25 +398,21 @@ public class TestDocBasedVersionConstraints extends SolrTestCaseJ4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Callable<Object> delayedAdd(final String... fields) {
|
private Callable<Object> delayedAdd(final String... fields) {
|
||||||
return Executors.callable(new Runnable() {
|
return Executors.callable(() -> {
|
||||||
public void run() {
|
// log.info("ADDING DOC: " + adoc(fields));
|
||||||
// log.info("ADDING DOC: " + adoc(fields));
|
assertU(adoc(fields));
|
||||||
assertU(adoc(fields));
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
private Callable<Object> delayedDelete(final String id, final String externalVersion) {
|
private Callable<Object> delayedDelete(final String id, final String externalVersion) {
|
||||||
return Executors.callable(new Runnable() {
|
return Executors.callable(() -> {
|
||||||
public void run() {
|
try {
|
||||||
try {
|
// Why does this throw "Exception" ???
|
||||||
// Why does this throw "Exception" ???
|
// log.info("DELETING DOC: " + id + " v="+externalVersion);
|
||||||
// log.info("DELETING DOC: " + id + " v="+externalVersion);
|
deleteAndGetVersion(id, params("del_version", externalVersion));
|
||||||
deleteAndGetVersion(id, params("del_version", externalVersion));
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
throw new RuntimeException(e);
|
||||||
throw new RuntimeException(e);
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -656,14 +656,11 @@ public class LBHttpSolrClient extends SolrClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Runnable getAliveCheckRunner(final WeakReference<LBHttpSolrClient> lbRef) {
|
private static Runnable getAliveCheckRunner(final WeakReference<LBHttpSolrClient> lbRef) {
|
||||||
return new Runnable() {
|
return () -> {
|
||||||
@Override
|
LBHttpSolrClient lb = lbRef.get();
|
||||||
public void run() {
|
if (lb != null && lb.zombieServers != null) {
|
||||||
LBHttpSolrClient lb = lbRef.get();
|
for (ServerWrapper zombieServer : lb.zombieServers.values()) {
|
||||||
if (lb != null && lb.zombieServers != null) {
|
lb.checkAZombieServer(zombieServer);
|
||||||
for (ServerWrapper zombieServer : lb.zombieServers.values()) {
|
|
||||||
lb.checkAZombieServer(zombieServer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -263,12 +263,7 @@ public class SolrZkClient implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void process(final WatchedEvent event) {
|
public void process(final WatchedEvent event) {
|
||||||
log.debug("Submitting job to respond to event " + event);
|
log.debug("Submitting job to respond to event " + event);
|
||||||
zkCallbackExecutor.submit(new Runnable () {
|
zkCallbackExecutor.submit(() -> watcher.process(event));
|
||||||
@Override
|
|
||||||
public void run () {
|
|
||||||
watcher.process(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -338,15 +338,12 @@ public class ZkStateReader implements Closeable {
|
|||||||
updateAliases();
|
updateAliases();
|
||||||
|
|
||||||
if (securityNodeListener != null) {
|
if (securityNodeListener != null) {
|
||||||
addSecuritynodeWatcher(new Callable<Pair<byte[], Stat>>() {
|
addSecuritynodeWatcher(pair -> {
|
||||||
@Override
|
ConfigData cd = new ConfigData();
|
||||||
public void call(Pair<byte[], Stat> pair) {
|
cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
|
||||||
ConfigData cd = new ConfigData();
|
cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
|
||||||
cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
|
securityData = cd;
|
||||||
cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
|
securityNodeListener.run();
|
||||||
securityData = cd;
|
|
||||||
securityNodeListener.run();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
securityData = getSecurityProps(true);
|
securityData = getSecurityProps(true);
|
||||||
}
|
}
|
||||||
|
@ -211,42 +211,39 @@ public class ExecutorUtil {
|
|||||||
providersCopy.get(i).store(reference);
|
providersCopy.get(i).store(reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.execute(new Runnable() {
|
super.execute(() -> {
|
||||||
@Override
|
isServerPool.set(Boolean.TRUE);
|
||||||
public void run() {
|
if (ctx != null) {
|
||||||
isServerPool.set(Boolean.TRUE);
|
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).set(ctx.get(i));
|
||||||
if (ctx != null) {
|
}
|
||||||
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).set(ctx.get(i));
|
Map<String, String> threadContext = MDC.getCopyOfContextMap();
|
||||||
|
final Thread currentThread = Thread.currentThread();
|
||||||
|
final String oldName = currentThread.getName();
|
||||||
|
if (submitterContext != null && !submitterContext.isEmpty()) {
|
||||||
|
MDC.setContextMap(submitterContext);
|
||||||
|
currentThread.setName(oldName + "-processing-" + submitterContextStr);
|
||||||
|
} else {
|
||||||
|
MDC.clear();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
command.run();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (t instanceof OutOfMemoryError) {
|
||||||
|
throw t;
|
||||||
}
|
}
|
||||||
Map<String, String> threadContext = MDC.getCopyOfContextMap();
|
log.error("Uncaught exception {} thrown by thread: {}", t, currentThread.getName(), submitterStackTrace);
|
||||||
final Thread currentThread = Thread.currentThread();
|
throw t;
|
||||||
final String oldName = currentThread.getName();
|
} finally {
|
||||||
if (submitterContext != null && !submitterContext.isEmpty()) {
|
isServerPool.remove();
|
||||||
MDC.setContextMap(submitterContext);
|
if (threadContext != null && !threadContext.isEmpty()) {
|
||||||
currentThread.setName(oldName + "-processing-" + submitterContextStr);
|
MDC.setContextMap(threadContext);
|
||||||
} else {
|
} else {
|
||||||
MDC.clear();
|
MDC.clear();
|
||||||
}
|
}
|
||||||
try {
|
if (ctx != null) {
|
||||||
command.run();
|
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).clean(ctx.get(i));
|
||||||
} catch (Throwable t) {
|
|
||||||
if (t instanceof OutOfMemoryError) {
|
|
||||||
throw t;
|
|
||||||
}
|
|
||||||
log.error("Uncaught exception {} thrown by thread: {}", t, currentThread.getName(), submitterStackTrace);
|
|
||||||
throw t;
|
|
||||||
} finally {
|
|
||||||
isServerPool.remove();
|
|
||||||
if (threadContext != null && !threadContext.isEmpty()) {
|
|
||||||
MDC.setContextMap(threadContext);
|
|
||||||
} else {
|
|
||||||
MDC.clear();
|
|
||||||
}
|
|
||||||
if (ctx != null) {
|
|
||||||
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).clean(ctx.get(i));
|
|
||||||
}
|
|
||||||
currentThread.setName(oldName);
|
|
||||||
}
|
}
|
||||||
|
currentThread.setName(oldName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -201,12 +201,9 @@ public class SolrParamTest extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Malformed params: These should throw a 400
|
// Malformed params: These should throw a 400
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> params.getInt("f.bad.int")));
|
||||||
public void run() { params.getInt( "f.bad.int" ); } } ) );
|
assertEquals(400, getReturnCode(() -> params.getBool("f.bad.bool")));
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> params.getFloat("f.bad.float")));
|
||||||
public void run() { params.getBool( "f.bad.bool" ); } } ) );
|
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
|
||||||
public void run() { params.getFloat( "f.bad.float" ); } } ) );
|
|
||||||
|
|
||||||
// Ask for params that arent there
|
// Ask for params that arent there
|
||||||
assertNull( params.get( "asagdsaga" ) );
|
assertNull( params.get( "asagdsaga" ) );
|
||||||
@ -243,24 +240,15 @@ public class SolrParamTest extends LuceneTestCase {
|
|||||||
assertEquals( pfloat , required.getFieldFloat( "fakefield", "float" ) );
|
assertEquals( pfloat , required.getFieldFloat( "fakefield", "float" ) );
|
||||||
|
|
||||||
// Required params which are missing: These should throw a 400
|
// Required params which are missing: These should throw a 400
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> required.get("aaaa")));
|
||||||
public void run() { required.get( "aaaa" ); } } ) );
|
assertEquals(400, getReturnCode(() -> required.getInt("f.bad.int")));
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> required.getBool("f.bad.bool")));
|
||||||
public void run() { required.getInt( "f.bad.int" ); } } ) );
|
assertEquals(400, getReturnCode(() -> required.getFloat("f.bad.float")));
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> required.getInt("aaa")));
|
||||||
public void run() { required.getBool( "f.bad.bool" ); } } ) );
|
assertEquals(400, getReturnCode(() -> required.getBool("aaa")));
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> required.getFloat("aaa")));
|
||||||
public void run() { required.getFloat( "f.bad.float" ); } } ) );
|
assertEquals(400, getReturnCode(() -> params.getFieldBool("bad", "bool")));
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
assertEquals(400, getReturnCode(() -> params.getFieldInt("bad", "int")));
|
||||||
public void run() { required.getInt( "aaa" ); } } ) );
|
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
|
||||||
public void run() { required.getBool( "aaa" ); } } ) );
|
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
|
||||||
public void run() { required.getFloat( "aaa" ); } } ) );
|
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
|
||||||
public void run() { params.getFieldBool( "bad", "bool" ); } } ) );
|
|
||||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
|
||||||
public void run() { params.getFieldInt( "bad", "int" ); } } ) );
|
|
||||||
|
|
||||||
// Fields with default use their parent value:
|
// Fields with default use their parent value:
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -442,17 +442,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
|||||||
final int ITERS = 1000000;
|
final int ITERS = 1000000;
|
||||||
int THREADS = 10;
|
int THREADS = 10;
|
||||||
|
|
||||||
runInThreads(THREADS, new Runnable() {
|
runInThreads(THREADS, () -> {
|
||||||
@Override
|
JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0], 0, 0);
|
||||||
public void run() {
|
for (int i = 0; i < ITERS; i++) {
|
||||||
JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0], 0, 0);
|
JavaBinCodec.StringBytes b = l.get(i % l.size());
|
||||||
for (int i = 0; i < ITERS; i++) {
|
stringBytes1.reset(b.bytes, 0, b.bytes.length);
|
||||||
JavaBinCodec.StringBytes b = l.get(i % l.size());
|
if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
|
||||||
stringBytes1.reset(b.bytes, 0, b.bytes.length);
|
|
||||||
if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -461,17 +458,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
|||||||
System.out.println("time taken by LRUCACHE " + timer.getTime());
|
System.out.println("time taken by LRUCACHE " + timer.getTime());
|
||||||
timer = new RTimer();
|
timer = new RTimer();
|
||||||
|
|
||||||
runInThreads(THREADS, new Runnable() {
|
runInThreads(THREADS, () -> {
|
||||||
@Override
|
String a = null;
|
||||||
public void run() {
|
CharArr arr = new CharArr();
|
||||||
String a = null;
|
for (int i = 0; i < ITERS; i++) {
|
||||||
CharArr arr = new CharArr();
|
JavaBinCodec.StringBytes sb = l.get(i % l.size());
|
||||||
for (int i = 0; i < ITERS; i++) {
|
arr.reset();
|
||||||
JavaBinCodec.StringBytes sb = l.get(i % l.size());
|
ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
|
||||||
arr.reset();
|
a = arr.toString();
|
||||||
ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
|
|
||||||
a = arr.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -574,14 +568,11 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
|||||||
if (nThreads <= 0) {
|
if (nThreads <= 0) {
|
||||||
ret += doDecode(buffers, iter, stringCache);
|
ret += doDecode(buffers, iter, stringCache);
|
||||||
} else {
|
} else {
|
||||||
runInThreads(nThreads, new Runnable() {
|
runInThreads(nThreads, () -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
doDecode(buffers, iter, stringCache);
|
||||||
try {
|
} catch (IOException e) {
|
||||||
doDecode(buffers, iter, stringCache);
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1612,12 +1612,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||||||
final int mul = asc ? 1 : -1;
|
final int mul = asc ? 1 : -1;
|
||||||
|
|
||||||
if (field.equals("_docid_")) {
|
if (field.equals("_docid_")) {
|
||||||
return new Comparator<Doc>() {
|
return (o1, o2) -> (o1.order - o2.order) * mul;
|
||||||
@Override
|
|
||||||
public int compare(Doc o1, Doc o2) {
|
|
||||||
return (o1.order - o2.order) * mul;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.equals("score")) {
|
if (field.equals("score")) {
|
||||||
@ -1669,16 +1664,13 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Comparator<Doc> createComparator(final List<Comparator<Doc>> comparators) {
|
public static Comparator<Doc> createComparator(final List<Comparator<Doc>> comparators) {
|
||||||
return new Comparator<Doc>() {
|
return (o1, o2) -> {
|
||||||
@Override
|
int c = 0;
|
||||||
public int compare(Doc o1, Doc o2) {
|
for (Comparator<Doc> comparator : comparators) {
|
||||||
int c = 0;
|
c = comparator.compare(o1, o2);
|
||||||
for (Comparator<Doc> comparator : comparators) {
|
if (c!=0) return c;
|
||||||
c = comparator.compare(o1, o2);
|
|
||||||
if (c!=0) return c;
|
|
||||||
}
|
|
||||||
return o1.order - o2.order;
|
|
||||||
}
|
}
|
||||||
|
return o1.order - o2.order;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user