Skip to content

Commit

Permalink
minor improve
Browse files Browse the repository at this point in the history
  • Loading branch information
VGalaxies committed Oct 23, 2024
1 parent 7b6fdea commit b3d8c4a
Show file tree
Hide file tree
Showing 9 changed files with 716 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.hugegraph.store.HgScanQuery;
import org.apache.hugegraph.store.client.HgStoreNodeSession;
import org.apache.hugegraph.store.client.type.HgStoreClientException;
import org.apache.hugegraph.store.client.util.Base58;
import org.apache.hugegraph.store.util.Base58Encoder;
import org.apache.hugegraph.store.client.util.HgStoreClientConfig;
import org.apache.hugegraph.store.grpc.common.Kv;
import org.apache.hugegraph.store.grpc.stream.HgStoreStreamGrpc;
Expand Down Expand Up @@ -107,7 +107,7 @@ private static class OrderBroker {

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

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import java.nio.ByteBuffer;
import java.util.UUID;

import org.apache.hugegraph.store.util.Base58Encoder;

public final class HgUuid {

private static String encode(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return Base58.encode(bb.array());
return Base58Encoder.convertToBase58(bb.array());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
public class HgPair<K, V> implements Serializable {

/**
* Key of this <code>Pair</code>.
* This is the key associated with this <code>Pair</code>.
*/
private K key;

/**
* Value of this <code>Pair</code>.
* This is the value associated with this <code>Pair</code>.
*/
private V value;

Expand All @@ -36,20 +37,20 @@ public HgPair() {
}

/**
* Creates a new pair
* Initializes a new pair with the specified key and value.
*
* @param key The key for this pair
* @param value The value to use for this pair
* @param key The key to be associated with this pair
* @param value The value to be associated with this pair
*/
public HgPair(K key, V value) {
this.key = key;
this.value = value;
}

/**
* Gets the key for this pair.
* Retrieves the key associated with this pair.
*
* @return key for this pair
* @return the key of this pair
*/
public K getKey() {
return key;
Expand All @@ -60,9 +61,9 @@ public void setKey(K key) {
}

/**
* Gets the value for this pair.
* Retrieves the value associated with this pair.
*
* @return value for this pair
* @return the value of this pair
*/
public V getValue() {
return value;
Expand All @@ -73,63 +74,54 @@ public void setValue(V value) {
}

/**
* <p><code>String</code> representation of this
* <code>Pair</code>.</p>
* Provides a <code>String</code> representation of this <code>Pair</code>.
*
* <p>The default name/value delimiter '=' is always used.</p>
* <p>The default delimiter between name and value is '='.</p>
*
* @return <code>String</code> representation of this <code>Pair</code>
* @return a <code>String</code> representation of this <code>Pair</code>
*/
@Override
public String toString() {
return key + "=" + value;
}

/**
* <p>Generate a hash code for this <code>Pair</code>.</p>
* Generates a hash code for this <code>Pair</code>.
*
* <p>The hash code is calculated using both the name and
* <p>The hash code is computed using both the key and
* the value of the <code>Pair</code>.</p>
*
* @return hash code for this <code>Pair</code>
* @return the hash code for this <code>Pair</code>
*/
@Override
public int hashCode() {
// name's hashCode is multiplied by an arbitrary prime number (13)
// in order to make sure there is a difference in the hashCode between
// these two parameters:
// name: a value: aa
// name: aa value: a
// The hashCode of the key is multiplied by a prime number (13)
// to ensure uniqueness between different key-value combinations:
// key: a value: aa
// key: aa value: a
return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
}

/**
* <p>Test this <code>Pair</code> for equality with another
* <code>Object</code>.</p>
* Checks if this <code>Pair</code> is equal to another <code>Object</code>.
*
* <p>If the <code>Object</code> to be tested is not a
* <code>Pair</code> or is <code>null</code>, then this method
* returns <code>false</code>.</p>
* <p>This method returns <code>false</code> if the tested
* <code>Object</code> is not a <code>Pair</code> or is <code>null</code>.</p>
*
* <p>Two <code>Pair</code>s are considered equal if and only if
* both the names and values are equal.</p>
* <p>Two <code>Pair</code>s are equal if their keys and values are both equal.</p>
*
* @param o the <code>Object</code> to test for
* equality with this <code>Pair</code>
* @return <code>true</code> if the given <code>Object</code> is
* equal to this <code>Pair</code> else <code>false</code>
* @param o the <code>Object</code> to compare with this <code>Pair</code>
* @return <code>true</code> if the specified <code>Object</code> is
* equal to this <code>Pair</code>, otherwise <code>false</code>
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof HgPair) {
HgPair pair = (HgPair) o;
if (!Objects.equals(key, pair.key)) {
return false;
}
return Objects.equals(value, pair.value);
HgPair<?, ?> pair = (HgPair<?, ?>) o;
return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
}
return false;
}
Expand Down
Loading

0 comments on commit b3d8c4a

Please sign in to comment.