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 2020/10/26 01:50:21 UTC

[GitHub] [iotdb] SteveYurongSu opened a new pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

SteveYurongSu opened a new pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856


   JIRA: https://issues.apache.org/jira/projects/IOTDB/issues/IOTDB-938


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] samperson1997 merged pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
samperson1997 merged pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] SteveYurongSu commented on a change in pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
SteveYurongSu commented on a change in pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856#discussion_r511903365



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/IntGorillaDecoder.java
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.tsfile.encoding.decoder;
+
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.GORILLA_ENCODING_ENDING_INTEGER;
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.LEADING_ZERO_BITS_LENGTH_32BIT;
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.MEANINGFUL_XOR_BITS_LENGTH_32BIT;
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.VALUE_BITS_LENGTH_32BIT;
+
+import java.nio.ByteBuffer;
+
+/**
+ * <p> This class includes code modified from Michael Burman's gorilla-tsc project.
+ *
+ * <p> Copyright: 2016-2018 Michael Burman and/or other contributors
+ * <p> Project page: https://github.com/burmanm/gorilla-tsc
+ * <p> License: http://www.apache.org/licenses/LICENSE-2.0
+ */
+public class IntGorillaDecoder extends GorillaDecoderV2 {
+
+  protected int storedValue = 0;
+
+  @Override
+  public void reset() {
+    super.reset();
+    storedValue = 0;
+  }
+
+  @Override
+  public final int readInt(ByteBuffer in) {
+    int returnValue = storedValue;
+    if (!firstValueWasRead) {
+      flipByte(in);
+      storedValue = (int) readLong(VALUE_BITS_LENGTH_32BIT, in);
+      firstValueWasRead = true;
+      returnValue = storedValue;
+    }
+    cacheNext(in);
+    return returnValue;
+  }
+
+  protected int cacheNext(ByteBuffer in) {
+    readNext(in);
+    if (storedValue == GORILLA_ENCODING_ENDING_INTEGER) {
+      hasNext = false;
+    }
+    return storedValue;
+  }
+
+  @SuppressWarnings("squid:S128")
+  protected int readNext(ByteBuffer in) {
+    int controlBits = readNextClearBit(2, in);

Review comment:
       You're right. I've changed it.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] SteveYurongSu commented on pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
SteveYurongSu commented on pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856#issuecomment-716265175


   Performance report: https://cwiki.apache.org/confluence/display/IOTDB/IOTDB-938+Re-implement+Gorilla+encoding+algorithm


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] SteveYurongSu commented on pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
SteveYurongSu commented on pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856#issuecomment-716327507


   > https://github.com/apache/iotdb/pull/1856/checks?check_run_id=1306787563
   > Nice work! I invoked the sonar cloud for this pr, please check it. :)
   
   Done! Most code smells are from the legacy code, I've fixed them. Please have a check again :)


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] SteveYurongSu commented on pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
SteveYurongSu commented on pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856#issuecomment-718310834


   > Hi @SteveYurongSu , excellent work and impressive experiment result. Just one question: when will we remove `GORILLA_V1`? And should we change `GORILLA_V2` to `GORILLA` at that time?
   
   Thanks!
   
   `GORILLA_V1` can be completely replaced by `GORILLA_V2`. I think we can delete the code of `GORILLA_V1` and change `GORILLA_V2` to `GORILLA` in a new release version, but the premise is that we need to make a version upgrade tool.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] HTHou commented on a change in pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
HTHou commented on a change in pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856#discussion_r511743830



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/IntGorillaDecoder.java
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.tsfile.encoding.decoder;
+
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.GORILLA_ENCODING_ENDING_INTEGER;
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.LEADING_ZERO_BITS_LENGTH_32BIT;
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.MEANINGFUL_XOR_BITS_LENGTH_32BIT;
+import static org.apache.iotdb.tsfile.common.conf.TSFileConfig.VALUE_BITS_LENGTH_32BIT;
+
+import java.nio.ByteBuffer;
+
+/**
+ * <p> This class includes code modified from Michael Burman's gorilla-tsc project.
+ *
+ * <p> Copyright: 2016-2018 Michael Burman and/or other contributors
+ * <p> Project page: https://github.com/burmanm/gorilla-tsc
+ * <p> License: http://www.apache.org/licenses/LICENSE-2.0
+ */
+public class IntGorillaDecoder extends GorillaDecoderV2 {
+
+  protected int storedValue = 0;
+
+  @Override
+  public void reset() {
+    super.reset();
+    storedValue = 0;
+  }
+
+  @Override
+  public final int readInt(ByteBuffer in) {
+    int returnValue = storedValue;
+    if (!firstValueWasRead) {
+      flipByte(in);
+      storedValue = (int) readLong(VALUE_BITS_LENGTH_32BIT, in);
+      firstValueWasRead = true;
+      returnValue = storedValue;
+    }
+    cacheNext(in);
+    return returnValue;
+  }
+
+  protected int cacheNext(ByteBuffer in) {
+    readNext(in);
+    if (storedValue == GORILLA_ENCODING_ENDING_INTEGER) {
+      hasNext = false;
+    }
+    return storedValue;
+  }
+
+  @SuppressWarnings("squid:S128")
+  protected int readNext(ByteBuffer in) {
+    int controlBits = readNextClearBit(2, in);

Review comment:
       This `controlBits` can only be 0, 2 and 3, right? How do you think change it and the return type of method `readNextClearBit` to byte?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] HTHou commented on pull request #1856: [IOTDB-938] Re-implement Gorilla encoding algorithm

Posted by GitBox <gi...@apache.org>.
HTHou commented on pull request #1856:
URL: https://github.com/apache/iotdb/pull/1856#issuecomment-716284321


   https://github.com/apache/iotdb/pull/1856/checks?check_run_id=1306787563
   Nice work! I invoked the sonar cloud for this pr, please check it. :)


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org