Uploaded image for project: 'Apache IoTDB'
  1. Apache IoTDB
  2. IOTDB-1371

NPE when creating aligned timeseries and inserting with mismatched data type

    XMLWordPrintableJSON

Details

    Description

      When creating aligned timeseries and inserting with mismatched data type, the MNode will be null and a NullPointerException would be thrown.

      Here is the related test:

      @Test
        public void testCreateAlignedTimeseriesAndInsertWithMismatchDataType() {
          MManager manager = IoTDB.metaManager;
          try {
            manager.setStorageGroup(new PartialPath("root.laptop"));
            manager.createAlignedTimeSeries(
                new PartialPath("root.laptop.d1"),
                Arrays.asList("s1", "s2", "s3"),
                Arrays.asList(
                    TSDataType.valueOf("FLOAT"),
                    TSDataType.valueOf("INT64"),
                    TSDataType.valueOf("INT32")),
                Arrays.asList(
                    TSEncoding.valueOf("RLE"), TSEncoding.valueOf("RLE"), TSEncoding.valueOf("RLE")),
                compressionType);
      
            // construct an insertRowPlan with mismatch data type
            long time = 1L;
            TSDataType[] dataTypes =
                new TSDataType[] {TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32};
      
            String[] columns = new String[3];
            columns[0] = 2.0 + "";
            columns[1] = 10000 + "";
            columns[2] = 100 + "";
      
            InsertRowPlan insertRowPlan =
                new InsertRowPlan(
                    new PartialPath("root.laptop.d1"),
                    time,
                    new String[] {"(s1,s2,s3)"},
                    dataTypes,
                    columns);
            insertRowPlan.setMeasurementMNodes(
                new MeasurementMNode[insertRowPlan.getMeasurements().length]);
      
            // call getSeriesSchemasAndReadLockDevice
            MNode mNode = manager.getSeriesSchemasAndReadLockDevice(insertRowPlan);
            assertEquals(4, mNode.getMeasurementMNodeCount());
            assertNull(insertRowPlan.getMeasurementMNodes()[0]);
            assertEquals(1, insertRowPlan.getFailedMeasurementNumber());
      
          } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
          }
        }
      }
      
      

       

      Attachments

        Issue Links

          Activity

            People

              sunzesong Zesong Sun
              sunzesong Zesong Sun
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: