You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/05/08 06:58:07 UTC
lucene-solr:master: SOLR-9071: rename the getters in
org.apache.solr.common.util.Pair class
Repository: lucene-solr
Updated Branches:
refs/heads/master b42945ea9 -> d57e0de5e
SOLR-9071: rename the getters in org.apache.solr.common.util.Pair class
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d57e0de5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d57e0de5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d57e0de5
Branch: refs/heads/master
Commit: d57e0de5ea992417d97da6b39d26809b5b23adc4
Parents: b42945e
Author: Noble Paul <no...@apache.org>
Authored: Sun May 8 12:27:51 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Sun May 8 12:27:51 2016 +0530
----------------------------------------------------------------------
.../org/apache/solr/schema/IndexSchema.java | 6 ++--
.../org/apache/solr/util/TestInjection.java | 28 +++++++--------
.../apache/solr/common/cloud/ZkStateReader.java | 4 +--
.../java/org/apache/solr/common/util/Pair.java | 36 ++++++++++++--------
4 files changed, 40 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d57e0de5/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
----------------------------------------------------------------------
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 9e65332..46d5b87 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -1493,10 +1493,10 @@ public class IndexSchema {
return Stream.of(Handler.values())
.filter(it -> name == null || it.nameLower.equals(name))
.map(it -> new Pair<>(it.realName, it.fun.apply(this)))
- .filter(it->it.getValue() != null)
+ .filter(it->it.second() != null)
.collect(Collectors.toMap(
- Pair::getKey,
- Pair::getValue,
+ Pair::first,
+ Pair::second,
(v1, v2) -> v2,
LinkedHashMap::new));
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d57e0de5/solr/core/src/java/org/apache/solr/util/TestInjection.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/TestInjection.java b/solr/core/src/java/org/apache/solr/util/TestInjection.java
index 2be1df6..cc3f85d 100644
--- a/solr/core/src/java/org/apache/solr/util/TestInjection.java
+++ b/solr/core/src/java/org/apache/solr/util/TestInjection.java
@@ -101,8 +101,8 @@ public class TestInjection {
public static boolean injectRandomDelayInCoreCreation() {
if (randomDelayInCoreCreation != null) {
Pair<Boolean,Integer> pair = parseValue(randomDelayInCoreCreation);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
int delay = RANDOM.nextInt(randomDelayMaxInCoreCreationInSec);
log.info("Inject random core creation delay of {}s", delay);
@@ -119,8 +119,8 @@ public class TestInjection {
public static boolean injectNonGracefullClose(CoreContainer cc) {
if (cc.isShutDown() && nonGracefullClose != null) {
Pair<Boolean,Integer> pair = parseValue(nonGracefullClose);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
if (RANDOM.nextBoolean()) {
throw new TestShutdownFailError("Test exception for non graceful close");
@@ -157,8 +157,8 @@ public class TestInjection {
public static boolean injectFailReplicaRequests() {
if (failReplicaRequests != null) {
Pair<Boolean,Integer> pair = parseValue(failReplicaRequests);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
}
@@ -170,8 +170,8 @@ public class TestInjection {
public static boolean injectFailUpdateRequests() {
if (failUpdateRequests != null) {
Pair<Boolean,Integer> pair = parseValue(failUpdateRequests);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
}
@@ -183,8 +183,8 @@ public class TestInjection {
public static boolean injectNonExistentCoreExceptionAfterUnload(String cname) {
if (nonExistentCoreExceptionAfterUnload != null) {
Pair<Boolean,Integer> pair = parseValue(nonExistentCoreExceptionAfterUnload);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
throw new NonExistentCoreException("Core not found to unload: " + cname);
}
@@ -196,8 +196,8 @@ public class TestInjection {
public static boolean injectUpdateLogReplayRandomPause() {
if (updateLogReplayRandomPause != null) {
Pair<Boolean,Integer> pair = parseValue(updateLogReplayRandomPause);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
long rndTime = RANDOM.nextInt(1000);
log.info("inject random log replay delay of {}ms", rndTime);
@@ -215,8 +215,8 @@ public class TestInjection {
public static boolean injectUpdateRandomPause() {
if (updateRandomPause != null) {
Pair<Boolean,Integer> pair = parseValue(updateRandomPause);
- boolean enabled = pair.getKey();
- int chanceIn100 = pair.getValue();
+ boolean enabled = pair.first();
+ int chanceIn100 = pair.second();
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
long rndTime = RANDOM.nextInt(1000);
log.info("inject random update delay of {}ms", rndTime);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d57e0de5/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 55d8c83..eafad84 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -385,8 +385,8 @@ public class ZkStateReader implements Closeable {
if (securityNodeListener != null) {
addSecuritynodeWatcher(pair -> {
ConfigData cd = new ConfigData();
- cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
- cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
+ cd.data = pair.first() == null || pair.first().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.first()), 4, false);
+ cd.version = pair.second() == null ? -1 : pair.second().getVersion();
securityData = cd;
securityNodeListener.run();
});
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d57e0de5/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Pair.java b/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
index f87323c..c05e346 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
@@ -17,30 +17,36 @@
package org.apache.solr.common.util;
import java.io.Serializable;
+import java.util.Objects;
-public class Pair<K, V> implements Serializable {
- private K key;
+public class Pair<T1, T2> implements Serializable {
+ private final T1 first;
+ private final T2 second;
- public K getKey() {
- return key;
+ public T1 first() {
+ return first;
}
- private V value;
-
- public K _1() {
- return key;
+ public T2 second() {
+ return second;
}
- public V _2() {
- return value;
+ public Pair(T1 key, T2 value) {
+ this.first = key;
+ this.second = value;
}
- public V getValue() {
- return value;
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Pair) {
+ Pair that = (Pair) obj;
+ return Objects.equals(this.first, that.first) && Objects.equals(this.second, that.second);
+ }
+ return false;
}
- public Pair(K key, V value) {
- this.key = key;
- this.value = value;
+ @Override
+ public int hashCode() {
+ return (this.first == null ? 0 : this.first.hashCode()) ^ (this.second == null ? 0 : this.second.hashCode());
}
}
\ No newline at end of file