SteveYurongSu commented on issue #2124:
URL: https://github.com/apache/iotdb/issues/2124#issuecomment-735351593


   I think the bug is introduced by the merge strategy. When I set the 
`compaction_strategy` to `NO_COMPACTION`, everything works well.
   
   Here is the code to reproduce the case. (set the `compaction_strategy` to 
`LEVEL_COMPACTION`)
   
   ```java
   /*
    * 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;
   
   import java.util.ArrayList;
   import java.util.List;
   import org.apache.iotdb.rpc.IoTDBConnectionException;
   import org.apache.iotdb.rpc.StatementExecutionException;
   import org.apache.iotdb.rpc.TSStatusCode;
   import org.apache.iotdb.session.Session;
   import org.apache.iotdb.session.SessionDataSet;
   import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
   import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
   import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
   
   public class SessionExample {
   
     private static Session session;
   
     public static void main(String[] args)
         throws IoTDBConnectionException, StatementExecutionException {
       session = new Session("127.0.0.1", 6667, "root", "root");
       session.open(false);
   
       try {
         session.setStorageGroup("root.storagegroup");
       } catch (StatementExecutionException e) {
         if (e.getStatusCode() != 
TSStatusCode.PATH_ALREADY_EXIST_ERROR.getStatusCode()) {
           throw e;
         }
       }
   
       createTimeseries();
       insertRecords();
       query();
       session.close();
     }
   
     private static void createTimeseries()
         throws IoTDBConnectionException, StatementExecutionException {
       for (int i = 1; i <= 10; ++i) {
         String path = "root.storagegroup.city.device";
         if (i < 10) {
           path += "000";
         } else if (i < 100) {
           path += "00";
         } else if (i < 1000) {
           path += "0";
         }
         path += i;
   
         String comsumption = path + ".comsumption";
         if (!session.checkTimeseriesExists(comsumption)) {
           session.createTimeseries(comsumption, TSDataType.FLOAT, 
TSEncoding.GORILLA,
               CompressionType.SNAPPY);
         }
         System.out.println(comsumption);
   
         String status = path + ".status";
         if (!session.checkTimeseriesExists(status)) {
           session.createTimeseries(status, TSDataType.FLOAT, 
TSEncoding.GORILLA,
               CompressionType.SNAPPY);
         }
         System.out.println(status);
       }
     }
   
     private static void insertRecords() throws IoTDBConnectionException, 
StatementExecutionException {
       for (int i = 1; i <= 10; ++i) {
         String deviceId = "root.storagegroup.city.device";
         if (i < 10) {
           deviceId += "000";
         } else if (i < 100) {
           deviceId += "00";
         } else if (i < 1000) {
           deviceId += "0";
         }
         deviceId += i;
   
         List<String> measurements = new ArrayList<>();
         measurements.add("comsumption");
         measurements.add("status");
   
         List<String> deviceIds = new ArrayList<>();
         List<List<String>> measurementsList = new ArrayList<>();
         List<List<Object>> valuesList = new ArrayList<>();
         List<Long> timestamps = new ArrayList<>();
         List<List<TSDataType>> typesList = new ArrayList<>();
   
         for (long time = 1546300800000L; time < 1546300800000L + 900000L * 
35040; time += 900000L) {
           List<Object> values = new ArrayList<>();
           List<TSDataType> types = new ArrayList<>();
           values.add(1.3f);
           values.add(1.0f);
           types.add(TSDataType.FLOAT);
           types.add(TSDataType.FLOAT);
   
           deviceIds.add(deviceId);
           measurementsList.add(measurements);
           timestamps.add(time);
           typesList.add(types);
           valuesList.add(values);
         }
   
         session.insertRecords(deviceIds, timestamps, measurementsList, 
typesList, valuesList);
       }
     }
   
     private static void query() throws IoTDBConnectionException, 
StatementExecutionException {
       for (int i = 1; i <= 10; ++i) {
         String deviceId = "root.storagegroup.city.device";
         if (i < 10) {
           deviceId += "000";
         } else if (i < 100) {
           deviceId += "00";
         } else if (i < 1000) {
           deviceId += "0";
         }
         deviceId += i;
   
         SessionDataSet dataSet = session.executeQueryStatement(String.format(
             "select count(comsumption), count(status) from %s where time >= 
1546300800000 and time < 1546560000000",
             deviceId));
         System.out.println(dataSet.getColumnNames());
         while (dataSet.hasNext()) {
           System.out.println(dataSet.next());
         }
         dataSet.closeOperationHandle();
       }
     }
   }
   ```
   
   The bug is first introduced by the commit `db4318302`.
   


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to