@@ -202,24 +202,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
202202import org.apache.iotdb.session.pool.SessionPool ;
203203import org.apache.tsfile.enums.TSDataType ;
204204import org.apache.tsfile.write.record.Tablet ;
205+ import org.apache.tsfile.write.schema.IMeasurementSchema ;
205206import org.apache.tsfile.write.schema.MeasurementSchema ;
206207
207208public class SessionPoolExample {
208- private static SessionPool sessionPool;
209- public static void main (String [] args ) throws IoTDBConnectionException , StatementExecutionException {
209+ private static SessionPool sessionPool;
210+ public static void main (String [] args ) throws IoTDBConnectionException , StatementExecutionException {
210211 // 1. init SessionPool
211212 constructSessionPool();
212213 // 2. execute insert data
213214 insertTabletExample();
214215 // 3. close SessionPool
215216 closeSessionPool();
216- }
217+ }
217218
218- private static void constructSessionPool () {
219+ private static void constructSessionPool () {
219220 // Using nodeUrls ensures that when one node goes down, other nodes are automatically connected to retry
220221 List<String > nodeUrls = new ArrayList<> ();
221222 nodeUrls. add(" 127.0.0.1:6667" );
222- nodeUrls. add(" 127.0.0.1:6668" );
223+ // nodeUrls.add("127.0.0.1:6668");
223224 sessionPool =
224225 new SessionPool .Builder ()
225226 .nodeUrls(nodeUrls)
@@ -240,31 +241,31 @@ public class SessionPoolExample {
240241 */
241242 // The schema of measurements of one device
242243 // only measurementId and data type in MeasurementSchema take effects in Tablet
243- List<MeasurementSchema > schemaList = new ArrayList<> ();
244+ List<IMeasurementSchema > schemaList = new ArrayList<> ();
244245 schemaList. add(new MeasurementSchema (" s1" , TSDataType . INT64 ));
245246 schemaList. add(new MeasurementSchema (" s2" , TSDataType . INT64 ));
246247 schemaList. add(new MeasurementSchema (" s3" , TSDataType . INT64 ));
247248
248- Tablet tablet = new Tablet (" root.sg.d1" , schemaList, 100 );
249+ Tablet tablet = new Tablet (" root.sg.d1" ,schemaList,100 );
249250
250251 // Method 1 to add tablet data
251252 long timestamp = System . currentTimeMillis();
252253
253254 Random random = new Random ();
254255 for (long row = 0 ; row < 100 ; row++ ) {
255- int rowIndex = tablet. rowSize ++ ;
256+ int rowIndex = tablet. getRowSize() ;
256257 tablet. addTimestamp(rowIndex, timestamp);
257258 for (int s = 0 ; s < 3 ; s++ ) {
258259 long value = random. nextLong();
259- tablet. addValue(schemaList. get(s). getMeasurementId (), rowIndex, value);
260+ tablet. addValue(schemaList. get(s). getMeasurementName (), rowIndex, value);
260261 }
261- if (tablet. rowSize == tablet. getMaxRowNumber()) {
262+ if (tablet. getRowSize() == tablet. getMaxRowNumber()) {
262263 sessionPool. insertTablet(tablet);
263264 tablet. reset();
264265 }
265266 timestamp++ ;
266267 }
267- if (tablet. rowSize != 0 ) {
268+ if (tablet. getRowSize() != 0 ) {
268269 sessionPool. insertTablet(tablet);
269270 tablet. reset();
270271 }
0 commit comments