This is an automated email from the ASF dual-hosted git repository. leirui pushed a commit to branch research/M4-visualization in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 724295aee605d5f94add92d8ad0f6c608fe84f72 Author: Lei Rui <[email protected]> AuthorDate: Mon Oct 10 15:55:06 2022 +0800 width 8 multiple faster, otherwise no --- .../test/java/org/apache/iotdb/session/MyBasicOperationTest3.java | 6 +++--- .../src/main/java/org/apache/iotdb/tsfile/utils/BytesUtils.java | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/session/src/test/java/org/apache/iotdb/session/MyBasicOperationTest3.java b/session/src/test/java/org/apache/iotdb/session/MyBasicOperationTest3.java index a281b1c117..bcbceb4d61 100644 --- a/session/src/test/java/org/apache/iotdb/session/MyBasicOperationTest3.java +++ b/session/src/test/java/org/apache/iotdb/session/MyBasicOperationTest3.java @@ -15,7 +15,7 @@ public class MyBasicOperationTest3 { int repeat = 1000000; int packNum = 128; - int packWidth = 2; + int packWidth = 13; DescriptiveStatistics op1 = new DescriptiveStatistics(); DescriptiveStatistics op2 = new DescriptiveStatistics(); for (int k = 0; k < repeat; k++) { @@ -25,8 +25,8 @@ public class MyBasicOperationTest3 { int high = 256; // exclusive byte[] buf = new byte[packNum * 8]; for (int i = 0; i < packNum; i++) { -// int v = r.nextInt(high - low) + low; - int v = 187; + int v = r.nextInt(high - low) + low; +// int v = 187; BytesUtils.longToBytes(v, buf, i * packWidth, packWidth); } diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BytesUtils.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BytesUtils.java index 49dee499e8..94e9d83548 100644 --- a/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BytesUtils.java +++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BytesUtils.java @@ -590,7 +590,8 @@ public class BytesUtils { TsFileConstant.bytesToLong_byteNum1_smallByte++; int mask = (int) Math.pow(2, 8 - width) - 1; // TODO consider if this to make static mask = (~mask & 0xff) >> startPosInByte; - return (result[startByte] & 0xff & mask) >> (7 - endPosInByte); +// return (result[startByte] & 0xff & mask) >> (7 - endPosInByte); + return (result[startByte] & mask) >> (7 - endPosInByte); } } // TODO if across two bytes @@ -607,7 +608,7 @@ public class BytesUtils { TsFileConstant.byteToLong_byteNums_firstByte_smallByte++; int mask = (int) Math.pow(2, 8 - startPosInByte) - 1; // TODO consider if this to make static - value = value | ((result[startByte] & 0xff & mask) << shift); + value = value | ((result[startByte] & mask) << shift); } // 2. deal with the last byte @@ -620,7 +621,8 @@ public class BytesUtils { TsFileConstant.byteToLong_byteNums_lastByte_smallByte++; int mask = (int) Math.pow(2, 7 - endPosInByte) - 1; // TODO consider if this to make static - value = value | ((result[endByte] & 0xff & ~mask) >> (7 - endPosInByte)); + value = value | ((result[endByte] & 0xff & ~mask) >> (7 + - endPosInByte)); // here mask is negative so need &0xff } // 3. deal with the middle bytes
