Skip to content

Commit bda73eb

Browse files
committed
minor improve
1 parent 7b6fdea commit bda73eb

File tree

10 files changed

+881
-545
lines changed

10 files changed

+881
-545
lines changed

hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/grpc/KvBatchScanner5.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.apache.hugegraph.store.HgScanQuery;
3636
import org.apache.hugegraph.store.client.HgStoreNodeSession;
3737
import org.apache.hugegraph.store.client.type.HgStoreClientException;
38-
import org.apache.hugegraph.store.client.util.Base58;
38+
import org.apache.hugegraph.store.util.Base58Encoder;
3939
import org.apache.hugegraph.store.client.util.HgStoreClientConfig;
4040
import org.apache.hugegraph.store.grpc.common.Kv;
4141
import org.apache.hugegraph.store.grpc.stream.HgStoreStreamGrpc;
@@ -107,7 +107,7 @@ private static class OrderBroker {
107107

108108
if (log.isDebugEnabled()) {
109109
if (scanQuery.getPrefixList() != null && scanQuery.getPrefixList().size() > 0) {
110-
brokerId = Base58.encode(scanQuery.getPrefixList().get(0).getKey());
110+
brokerId = Base58Encoder.convertToBase58(scanQuery.getPrefixList().get(0).getKey());
111111

112112
log.debug(
113113
"[ANALYSIS START] [{}] firstKey: {}, keyLength: {}, table: {}, node: {}"

hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/util/Base58.java

-166
This file was deleted.

hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/util/HgUuid.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
import java.nio.ByteBuffer;
2121
import java.util.UUID;
2222

23+
import org.apache.hugegraph.store.util.Base58Encoder;
24+
2325
public final class HgUuid {
2426

2527
private static String encode(UUID uuid) {
2628
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
2729
bb.putLong(uuid.getMostSignificantBits());
2830
bb.putLong(uuid.getLeastSignificantBits());
29-
return Base58.encode(bb.array());
31+
return Base58Encoder.convertToBase58(bb.array());
3032
}
3133

3234
/**

hugegraph-store/hg-store-common/src/main/java/org/apache/hugegraph/store/term/HgPair.java

+29-37
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
public class HgPair<K, V> implements Serializable {
2424

2525
/**
26-
* Key of this <code>Pair</code>.
26+
* This is the key associated with this <code>Pair</code>.
2727
*/
2828
private K key;
29+
2930
/**
30-
* Value of this <code>Pair</code>.
31+
* This is the value associated with this <code>Pair</code>.
3132
*/
3233
private V value;
3334

@@ -36,20 +37,20 @@ public HgPair() {
3637
}
3738

3839
/**
39-
* Creates a new pair
40+
* Initializes a new pair with the specified key and value.
4041
*
41-
* @param key The key for this pair
42-
* @param value The value to use for this pair
42+
* @param key The key to be associated with this pair
43+
* @param value The value to be associated with this pair
4344
*/
4445
public HgPair(K key, V value) {
4546
this.key = key;
4647
this.value = value;
4748
}
4849

4950
/**
50-
* Gets the key for this pair.
51+
* Retrieves the key associated with this pair.
5152
*
52-
* @return key for this pair
53+
* @return the key of this pair
5354
*/
5455
public K getKey() {
5556
return key;
@@ -60,9 +61,9 @@ public void setKey(K key) {
6061
}
6162

6263
/**
63-
* Gets the value for this pair.
64+
* Retrieves the value associated with this pair.
6465
*
65-
* @return value for this pair
66+
* @return the value of this pair
6667
*/
6768
public V getValue() {
6869
return value;
@@ -73,63 +74,54 @@ public void setValue(V value) {
7374
}
7475

7576
/**
76-
* <p><code>String</code> representation of this
77-
* <code>Pair</code>.</p>
77+
* Provides a <code>String</code> representation of this <code>Pair</code>.
7878
*
79-
* <p>The default name/value delimiter '=' is always used.</p>
79+
* <p>The default delimiter between name and value is '='.</p>
8080
*
81-
* @return <code>String</code> representation of this <code>Pair</code>
81+
* @return a <code>String</code> representation of this <code>Pair</code>
8282
*/
8383
@Override
8484
public String toString() {
8585
return key + "=" + value;
8686
}
8787

8888
/**
89-
* <p>Generate a hash code for this <code>Pair</code>.</p>
89+
* Generates a hash code for this <code>Pair</code>.
9090
*
91-
* <p>The hash code is calculated using both the name and
91+
* <p>The hash code is computed using both the key and
9292
* the value of the <code>Pair</code>.</p>
9393
*
94-
* @return hash code for this <code>Pair</code>
94+
* @return the hash code for this <code>Pair</code>
9595
*/
9696
@Override
9797
public int hashCode() {
98-
// name's hashCode is multiplied by an arbitrary prime number (13)
99-
// in order to make sure there is a difference in the hashCode between
100-
// these two parameters:
101-
// name: a value: aa
102-
// name: aa value: a
98+
// The hashCode of the key is multiplied by a prime number (13)
99+
// to ensure uniqueness between different key-value combinations:
100+
// key: a value: aa
101+
// key: aa value: a
103102
return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
104103
}
105104

106105
/**
107-
* <p>Test this <code>Pair</code> for equality with another
108-
* <code>Object</code>.</p>
106+
* Checks if this <code>Pair</code> is equal to another <code>Object</code>.
109107
*
110-
* <p>If the <code>Object</code> to be tested is not a
111-
* <code>Pair</code> or is <code>null</code>, then this method
112-
* returns <code>false</code>.</p>
108+
* <p>This method returns <code>false</code> if the tested
109+
* <code>Object</code> is not a <code>Pair</code> or is <code>null</code>.</p>
113110
*
114-
* <p>Two <code>Pair</code>s are considered equal if and only if
115-
* both the names and values are equal.</p>
111+
* <p>Two <code>Pair</code>s are equal if their keys and values are both equal.</p>
116112
*
117-
* @param o the <code>Object</code> to test for
118-
* equality with this <code>Pair</code>
119-
* @return <code>true</code> if the given <code>Object</code> is
120-
* equal to this <code>Pair</code> else <code>false</code>
113+
* @param o the <code>Object</code> to compare with this <code>Pair</code>
114+
* @return <code>true</code> if the specified <code>Object</code> is
115+
* equal to this <code>Pair</code>, otherwise <code>false</code>
121116
*/
122117
@Override
123118
public boolean equals(Object o) {
124119
if (this == o) {
125120
return true;
126121
}
127122
if (o instanceof HgPair) {
128-
HgPair pair = (HgPair) o;
129-
if (!Objects.equals(key, pair.key)) {
130-
return false;
131-
}
132-
return Objects.equals(value, pair.value);
123+
HgPair<?, ?> pair = (HgPair<?, ?>) o;
124+
return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
133125
}
134126
return false;
135127
}

0 commit comments

Comments
 (0)