You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/01/01 03:01:06 UTC
[GitHub] [iotdb] xingtanzjr commented on a change in pull request #4676: [IOTDB-2205] Optimize unaligned int/long read/write functions in BytesUtils
xingtanzjr commented on a change in pull request #4676:
URL: https://github.com/apache/iotdb/pull/4676#discussion_r777076128
##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BytesUtils.java
##########
@@ -495,19 +518,35 @@ public static boolean bytesToBool(byte[] b, int offset) {
* @param width bit-width
*/
public static void longToBytes(long srcNum, byte[] result, int pos, int width) {
- int temp = 0;
- for (int i = 0; i < width; i++) {
- temp = (pos + width - 1 - i) / 8;
- try {
- result[temp] = setByteN(result[temp], pos + width - 1 - i, getLongN(srcNum, i));
- } catch (Exception e) {
- LOG.error(
- "tsfile-common BytesUtils: cannot convert a long {} to a byte array, pos {}, width {}",
- srcNum,
- pos,
- width,
- e);
+ if (width < 64) {
+ srcNum = srcNum & ~(-1L << width);
Review comment:
We can consider to remove this `pre-processing` for `srcNum` because the `scrNum` will always be represented by `width` bits if this method is invoked
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org