[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #2095: refact: mark TODO in the license problem code & use standard UTF-8
javeme commented on code in PR #2095:
URL:
https://github.com/apache/incubator-hugegraph/pull/2095#discussion_r1123222993
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -137,18 +129,23 @@ public static byte[] compress(String value) {
}
public static byte[] compress(String value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
- bufferRatio);
-return buf.bytes();
+try (BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
bufferRatio)) {
+return buf.bytes();
+} catch (IOException e) {
Review Comment:
yes the BytesBuffer don't need to close, it's just a memory buffer
--
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]
[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #2095: refact: mark TODO in the license problem code & use standard UTF-8
javeme commented on code in PR #2095:
URL:
https://github.com/apache/incubator-hugegraph/pull/2095#discussion_r1123076734
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -137,26 +127,30 @@ public static byte[] compress(String value) {
}
public static byte[] compress(String value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
- bufferRatio);
-return buf.bytes();
+try (BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
bufferRatio)) {
+return buf.bytes();
+} catch (IOException e) {
+throw new RuntimeException(e);
Review Comment:
wrap a message for the re-throw, like "Failed to compress xx"
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -137,18 +129,23 @@ public static byte[] compress(String value) {
}
public static byte[] compress(String value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
- bufferRatio);
-return buf.bytes();
+try (BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
bufferRatio)) {
+return buf.bytes();
+} catch (IOException e) {
Review Comment:
yes just remove the catch, since the LZ4Util.compress already transfer
IOException to BackendException
--
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]
[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #2095: refact: mark TODO in the license problem code & use standard UTF-8
javeme commented on code in PR #2095:
URL:
https://github.com/apache/incubator-hugegraph/pull/2095#discussion_r1101532429
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -14,19 +14,22 @@
package org.apache.hugegraph.util;
-import java.io.UnsupportedEncodingException;
+import static java.nio.charset.StandardCharsets.UTF_8;
Review Comment:
don't import static as possible, import StandardCharsets instead, and can
define a static final UTF8 = StandardCharsets.UTF_8
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -137,18 +129,23 @@ public static byte[] compress(String value) {
}
public static byte[] compress(String value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
- bufferRatio);
-return buf.bytes();
+try (BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
bufferRatio)) {
+return buf.bytes();
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
}
public static String decompress(byte[] value) {
return decompress(value, LZ4Util.DEFAULT_BUFFER_RATIO);
}
public static String decompress(byte[] value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.decompress(value, BLOCK_SIZE, bufferRatio);
-return decode(buf.array(), 0, buf.position());
+try (BytesBuffer buf = LZ4Util.decompress(value, BLOCK_SIZE,
bufferRatio)) {
+return decode(buf.array(), 0, buf.position());
+} catch (IOException e) {
Review Comment:
seems don't need to catch IOException
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -92,33 +96,21 @@ public static int getAsciiByteLength(String value) {
}
public static byte[] encode(String value) {
-try {
-return value.getBytes("UTF-8");
-} catch (UnsupportedEncodingException e) {
-throw new HugeException("Failed to encode string", e);
-}
+return value.getBytes(UTF_8);
Review Comment:
ok
--
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]
[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #2095: refact: mark TODO in the license problem code & use standard UTF-8
javeme commented on code in PR #2095:
URL:
https://github.com/apache/incubator-hugegraph/pull/2095#discussion_r1101418717
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -92,33 +96,21 @@ public static int getAsciiByteLength(String value) {
}
public static byte[] encode(String value) {
-try {
-return value.getBytes("UTF-8");
-} catch (UnsupportedEncodingException e) {
-throw new HugeException("Failed to encode string", e);
-}
+return value.getBytes(UTF_8);
Review Comment:
please don't change the logic
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -137,18 +129,23 @@ public static byte[] compress(String value) {
}
public static byte[] compress(String value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
- bufferRatio);
-return buf.bytes();
+try (BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
bufferRatio)) {
+return buf.bytes();
+} catch (IOException e) {
Review Comment:
seems don't need to catch IOException
##
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java:
##
@@ -137,18 +129,23 @@ public static byte[] compress(String value) {
}
public static byte[] compress(String value, float bufferRatio) {
-BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
- bufferRatio);
-return buf.bytes();
+try (BytesBuffer buf = LZ4Util.compress(encode(value), BLOCK_SIZE,
bufferRatio)) {
Review Comment:
keep the origin logic, or split into a new commit?
##
hugegraph-cassandra/src/main/java/org/apache/hugegraph/backend/store/cassandra/CassandraShard.java:
##
@@ -56,12 +56,13 @@
* CassandraShard is used for cassandra scanning operations.
* Each shard represents a range of tokens for a node.
* Reading data from a given shard does not cross multiple nodes.
+ *
* Refer to AbstractColumnFamilyInputFormat from:
* https://github.com/2013Commons/hive-cassandra/";>...
*/
public class CassandraShard {
-// The minimal shard size should >= 1M to prevent too many number of shards
+/** The minimal shard size should >= 1M to prevent too many number of
shards */
Review Comment:
ok
--
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]
[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #2095: refact: mark TODO in the license problem code & use standard UTF-8
javeme commented on code in PR #2095:
URL:
https://github.com/apache/incubator-hugegraph/pull/2095#discussion_r1083234806
##
hugegraph-cassandra/src/main/java/org/apache/hugegraph/backend/store/cassandra/CassandraShard.java:
##
@@ -56,12 +56,13 @@
* CassandraShard is used for cassandra scanning operations.
* Each shard represents a range of tokens for a node.
* Reading data from a given shard does not cross multiple nodes.
+ *
* Refer to AbstractColumnFamilyInputFormat from:
* https://github.com/2013Commons/hive-cassandra/";>...
*/
public class CassandraShard {
-// The minimal shard size should >= 1M to prevent too many number of shards
+/** The minimal shard size should >= 1M to prevent too many number of
shards */
Review Comment:
`/**` => `/*`
--
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]
