javeme commented on code in PR #2000:
URL:
https://github.com/apache/incubator-hugegraph/pull/2000#discussion_r1011842374
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/AbstractCache.java:
##########
@@ -248,7 +248,7 @@ public <T> T attachment() {
protected abstract Iterator<CacheNode<K, V>> nodes();
- protected static final long now() {
+ protected static long now() {
Review Comment:
better to mark final here
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Condition.java:
##########
@@ -58,25 +58,15 @@ public enum RelationType implements BiPredicate<Object,
Object> {
return equals(v1, v2);
}),
- GT(">", (v1, v2) -> {
- return compare(v1, v2) > 0;
- }),
+ GT(">", (v1, v2) -> compare(v1, v2) > 0),
- GTE(">=", (v1, v2) -> {
- return compare(v1, v2) >= 0;
- }),
+ GTE(">=", (v1, v2) -> compare(v1, v2) >= 0),
- LT("<", (v1, v2) -> {
- return compare(v1, v2) < 0;
- }),
+ LT("<", (v1, v2) -> compare(v1, v2) < 0),
- LTE("<=", (v1, v2) -> {
- return compare(v1, v2) <= 0;
- }),
+ LTE("<=", (v1, v2) -> compare(v1, v2) <= 0),
- NEQ("!=", (v1, v2) -> {
- return compare(v1, v2) != 0;
- }),
+ NEQ("!=", (v1, v2) -> compare(v1, v2) != 0),
Review Comment:
can we keep them for debug
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/AbstractCache.java:
##########
@@ -32,7 +32,7 @@
public abstract class AbstractCache<K, V> implements Cache<K, V> {
public static final int MB = 1024 * 1024;
- public static final int DEFAULT_SIZE = 1 * MB;
+ public static final int DEFAULT_SIZE = MB;
Review Comment:
prefer to keep the origin code for more readable
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/ConditionQuery.java:
##########
@@ -699,9 +693,9 @@ private static String escapeSpecialValueIfNeeded(String
value) {
if (value.isEmpty()) {
// Escape empty String to INDEX_SYM_EMPTY (char `\u0002`)
value = INDEX_SYM_EMPTY;
- } else if (value == INDEX_VALUE_EMPTY) {
+ } else if (INDEX_VALUE_EMPTY.equals(value)) {
Review Comment:
must keep "==" here since INDEX_VALUE_EMPTY is just a special symbol, we can
add some comments for it
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Query.java:
##########
@@ -568,7 +568,7 @@ public static long defaultCapacity() {
return capacity != null ? capacity : DEFAULT_CAPACITY;
}
- public static final void checkForceCapacity(long count)
+ public static void checkForceCapacity(long count)
Review Comment:
update alignment of the next line "throws LimitExceedException"
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/ram/IntObjectMap.java:
##########
@@ -28,18 +28,31 @@
public final class IntObjectMap<V> implements RamMap {
- private final Object[] array;
+ static final float DEFAULT_INITIAL_FACTOR = 0.5f;
Review Comment:
mark `private static final`, and add a blank line here
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/BinaryEntryIterator.java:
##########
@@ -77,7 +77,6 @@ protected final boolean fetch() {
this.current = merged;
} else if (merged == this.current) {
// The next entry belongs to the current entry
- assert this.current != null;
Review Comment:
better to keep it for more readable
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/BackendException.java:
##########
@@ -45,8 +45,8 @@ public BackendException(Throwable cause) {
this("Exception in backend", cause);
}
- public static final void check(boolean expression,
- String message, Object... args)
+ public static void check(boolean expression,
Review Comment:
better to mark final here
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/ram/IntObjectMap.java:
##########
@@ -62,4 +75,15 @@ public void writeTo(DataOutputStream buffer) throws
IOException {
public void readFrom(DataInputStream buffer) throws IOException {
throw new NotSupportException("IntObjectMap.readFrom");
}
+
+ private synchronized void expandCapacity() {
+ if (this.currentSize == this.maxSize) {
+ return;
+ }
+ this.currentSize = this.maxSize;
Review Comment:
prefer let `this.currentSize = min(this.currentSize * 2, this.maxSize)`;
##########
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/BinarySerializer.java:
##########
@@ -917,14 +917,12 @@ protected static boolean indexIdLengthExceedLimit(Id id) {
protected static boolean indexFieldValuesUnmatched(byte[] value,
Object fieldValues) {
if (value != null && value.length > 0 && fieldValues != null) {
- if (!StringEncoding.decode(value).equals(fieldValues)) {
- return true;
- }
+ return !StringEncoding.decode(value).equals(fieldValues);
}
return false;
}
- public static final byte[] increaseOne(byte[] bytes) {
+ public static byte[] increaseOne(byte[] bytes) {
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]