This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch iotdb_2599 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 8298bffb6bab205de1c9fdd23b09dd0224e54911 Author: HTHou <[email protected]> AuthorDate: Thu Feb 24 15:47:38 2022 +0800 [IOTDB-2599] Fix example of insertAlignedTablet is incorrect --- .../iotdb/AlignedTimeseriesSessionExample.java | 24 ++++++++-------------- .../iotdb/HybridTimeseriesSessionExample.java | 14 ++++++------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java b/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java index 82bb1c1..aa98341 100644 --- a/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java +++ b/example/session/src/main/java/org/apache/iotdb/AlignedTimeseriesSessionExample.java @@ -303,7 +303,6 @@ public class AlignedTimeseriesSessionExample { schemaList.add(new MeasurementSchema("s2", TSDataType.INT32)); Tablet tablet = new Tablet(ROOT_SG1_D1, schemaList); - tablet.setAligned(true); long timestamp = 1; for (long row = 1; row < 100; row++) { @@ -314,7 +313,7 @@ public class AlignedTimeseriesSessionExample { tablet.addValue(schemaList.get(1).getMeasurementId(), rowIndex, new SecureRandom().nextInt()); if (tablet.rowSize == tablet.getMaxRowNumber()) { - session.insertTablet(tablet, true); + session.insertAlignedTablet(tablet, true); tablet.reset(); } timestamp++; @@ -338,7 +337,6 @@ public class AlignedTimeseriesSessionExample { schemaList.add(new MeasurementSchema("s2", TSDataType.INT32)); Tablet tablet = new Tablet(ROOT_SG1_D1_VECTOR2, schemaList); - tablet.setAligned(true); long[] timestamps = tablet.timestamps; Object[] values = tablet.values; @@ -353,13 +351,13 @@ public class AlignedTimeseriesSessionExample { sensor2[row] = new SecureRandom().nextInt(); if (tablet.rowSize == tablet.getMaxRowNumber()) { - session.insertTablet(tablet, true); + session.insertAlignedTablet(tablet, true); tablet.reset(); } } if (tablet.rowSize != 0) { - session.insertTablet(tablet, true); + session.insertAlignedTablet(tablet, true); tablet.reset(); } @@ -375,7 +373,6 @@ public class AlignedTimeseriesSessionExample { schemaList.add(new MeasurementSchema("s2", TSDataType.INT32)); Tablet tablet = new Tablet(ROOT_SG1_D1_VECTOR3, schemaList); - tablet.setAligned(true); long[] timestamps = tablet.timestamps; Object[] values = tablet.values; @@ -400,14 +397,14 @@ public class AlignedTimeseriesSessionExample { } if (tablet.rowSize == tablet.getMaxRowNumber()) { - session.insertTablet(tablet, true); + session.insertAlignedTablet(tablet, true); tablet.reset(); bitMaps[1].reset(); } } if (tablet.rowSize != 0) { - session.insertTablet(tablet, true); + session.insertAlignedTablet(tablet, true); tablet.reset(); } @@ -559,9 +556,6 @@ public class AlignedTimeseriesSessionExample { Tablet tablet1 = new Tablet(ROOT_SG2_D1_VECTOR6, schemaList1, 100); Tablet tablet2 = new Tablet(ROOT_SG2_D1_VECTOR7, schemaList2, 100); Tablet tablet3 = new Tablet(ROOT_SG2_D1_VECTOR8, schemaList3, 100); - tablet1.setAligned(true); - tablet2.setAligned(true); - tablet3.setAligned(true); Map<String, Tablet> tabletMap = new HashMap<>(); tabletMap.put(ROOT_SG2_D1_VECTOR6, tablet1); @@ -584,7 +578,7 @@ public class AlignedTimeseriesSessionExample { tablet3.addValue(schemaList3.get(0).getSubMeasurementsList().get(i), row3, value); } if (tablet1.rowSize == tablet1.getMaxRowNumber()) { - session.insertTablets(tabletMap, true); + session.insertAlignedTablets(tabletMap, true); tablet1.reset(); tablet2.reset(); tablet3.reset(); @@ -593,7 +587,7 @@ public class AlignedTimeseriesSessionExample { } if (tablet1.rowSize != 0) { - session.insertTablets(tabletMap, true); + session.insertAlignedTablets(tabletMap, true); tablet1.reset(); tablet2.reset(); tablet3.reset(); @@ -623,7 +617,7 @@ public class AlignedTimeseriesSessionExample { sensor3[row3] = i; } if (tablet1.rowSize == tablet1.getMaxRowNumber()) { - session.insertTablets(tabletMap, true); + session.insertAlignedTablets(tabletMap, true); tablet1.reset(); tablet2.reset(); @@ -632,7 +626,7 @@ public class AlignedTimeseriesSessionExample { } if (tablet1.rowSize != 0) { - session.insertTablets(tabletMap, true); + session.insertAlignedTablets(tabletMap, true); tablet1.reset(); tablet2.reset(); tablet3.reset(); diff --git a/example/session/src/main/java/org/apache/iotdb/HybridTimeseriesSessionExample.java b/example/session/src/main/java/org/apache/iotdb/HybridTimeseriesSessionExample.java index 8186f81..d630482 100644 --- a/example/session/src/main/java/org/apache/iotdb/HybridTimeseriesSessionExample.java +++ b/example/session/src/main/java/org/apache/iotdb/HybridTimeseriesSessionExample.java @@ -36,7 +36,7 @@ import java.util.List; public class HybridTimeseriesSessionExample { private static Session session; - private static final String ROOT_SG1_D1_VECTOR1 = "root.sg_1.d1.vector"; + private static final String ROOT_SG1_ALIGNEDDEVICE = "root.sg_1.aligned_device"; private static final String ROOT_SG1_D1 = "root.sg_1.d1"; private static final String ROOT_SG1_D2 = "root.sg_1.d2"; @@ -58,7 +58,7 @@ public class HybridTimeseriesSessionExample { } private static void selectTest() throws StatementExecutionException, IoTDBConnectionException { - SessionDataSet dataSet = session.executeQueryStatement("select * from root.sg_1.d1"); + SessionDataSet dataSet = session.executeQueryStatement("select ** from root.sg_1"); System.out.println(dataSet.getColumnNames()); while (dataSet.hasNext()) { System.out.println(dataSet.next()); @@ -75,19 +75,17 @@ public class HybridTimeseriesSessionExample { schemaList.add(new MeasurementSchema("s1", TSDataType.INT64)); schemaList.add(new MeasurementSchema("s2", TSDataType.INT32)); - Tablet tablet = new Tablet(ROOT_SG1_D1_VECTOR1, schemaList); - tablet.setAligned(true); + Tablet tablet = new Tablet(ROOT_SG1_ALIGNEDDEVICE, schemaList); long timestamp = minTime; for (long row = minTime; row < maxTime; row++) { int rowIndex = tablet.rowSize++; tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue(schemaList.get(0).getSubMeasurementsList().get(0), rowIndex, row * 10 + 1L); - tablet.addValue( - schemaList.get(0).getSubMeasurementsList().get(1), rowIndex, (int) (row * 10 + 2)); + tablet.addValue(schemaList.get(0).getMeasurementId(), rowIndex, row * 10 + 1L); + tablet.addValue(schemaList.get(1).getMeasurementId(), rowIndex, (int) (row * 10 + 2)); if (tablet.rowSize == tablet.getMaxRowNumber()) { - session.insertTablet(tablet, true); + session.insertAlignedTablet(tablet, true); tablet.reset(); } timestamp++;
