Skip to content

Commit bd98fc7

Browse files
committed
update tablet functions
1 parent b824a13 commit bd98fc7

4 files changed

Lines changed: 48 additions & 44 deletions

File tree

src/UserGuide/Master/Tree/API/Programming-Java-Native-API.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
202202
import org.apache.iotdb.session.pool.SessionPool;
203203
import org.apache.tsfile.enums.TSDataType;
204204
import org.apache.tsfile.write.record.Tablet;
205+
import org.apache.tsfile.write.schema.IMeasurementSchema;
205206
import org.apache.tsfile.write.schema.MeasurementSchema;
206207

207208
public 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
}

src/UserGuide/latest/API/Programming-Java-Native-API.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
202202
import org.apache.iotdb.session.pool.SessionPool;
203203
import org.apache.tsfile.enums.TSDataType;
204204
import org.apache.tsfile.write.record.Tablet;
205+
import org.apache.tsfile.write.schema.IMeasurementSchema;
205206
import org.apache.tsfile.write.schema.MeasurementSchema;
206207

207208
public 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
}

src/zh/UserGuide/Master/Tree/API/Programming-Java-Native-API.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
200200
import org.apache.iotdb.session.pool.SessionPool;
201201
import org.apache.tsfile.enums.TSDataType;
202202
import org.apache.tsfile.write.record.Tablet;
203+
import org.apache.tsfile.write.schema.IMeasurementSchema;
203204
import org.apache.tsfile.write.schema.MeasurementSchema;
204205

205206
public class SessionPoolExample {
206-
private static SessionPool sessionPool;
207-
public static void main(String[] args) throws IoTDBConnectionException, StatementExecutionException {
207+
private static SessionPool sessionPool;
208+
public static void main(String[] args) throws IoTDBConnectionException, StatementExecutionException {
208209
// 1. init SessionPool
209210
constructSessionPool();
210211
// 2. execute insert data
211212
insertTabletExample();
212213
// 3. close SessionPool
213214
closeSessionPool();
214-
}
215+
}
215216

216-
private static void constructSessionPool() {
217+
private static void constructSessionPool() {
217218
// Using nodeUrls ensures that when one node goes down, other nodes are automatically connected to retry
218219
List<String> nodeUrls = new ArrayList<>();
219220
nodeUrls.add("127.0.0.1:6667");
220-
nodeUrls.add("127.0.0.1:6668");
221+
//nodeUrls.add("127.0.0.1:6668");
221222
sessionPool =
222223
new SessionPool.Builder()
223224
.nodeUrls(nodeUrls)
@@ -238,31 +239,31 @@ public class SessionPoolExample {
238239
*/
239240
// The schema of measurements of one device
240241
// only measurementId and data type in MeasurementSchema take effects in Tablet
241-
List<MeasurementSchema> schemaList = new ArrayList<>();
242+
List<IMeasurementSchema> schemaList = new ArrayList<>();
242243
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
243244
schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
244245
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
245246

246-
Tablet tablet = new Tablet("root.sg.d1", schemaList, 100);
247+
Tablet tablet = new Tablet("root.sg.d1",schemaList,100);
247248

248249
// Method 1 to add tablet data
249250
long timestamp = System.currentTimeMillis();
250251

251252
Random random = new Random();
252253
for (long row = 0; row < 100; row++) {
253-
int rowIndex = tablet.rowSize++;
254+
int rowIndex = tablet.getRowSize();
254255
tablet.addTimestamp(rowIndex, timestamp);
255256
for (int s = 0; s < 3; s++) {
256257
long value = random.nextLong();
257-
tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex, value);
258+
tablet.addValue(schemaList.get(s).getMeasurementName(), rowIndex, value);
258259
}
259-
if (tablet.rowSize == tablet.getMaxRowNumber()) {
260+
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
260261
sessionPool.insertTablet(tablet);
261262
tablet.reset();
262263
}
263264
timestamp++;
264265
}
265-
if (tablet.rowSize != 0) {
266+
if (tablet.getRowSize() != 0) {
266267
sessionPool.insertTablet(tablet);
267268
tablet.reset();
268269
}

src/zh/UserGuide/latest/API/Programming-Java-Native-API.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
200200
import org.apache.iotdb.session.pool.SessionPool;
201201
import org.apache.tsfile.enums.TSDataType;
202202
import org.apache.tsfile.write.record.Tablet;
203+
import org.apache.tsfile.write.schema.IMeasurementSchema;
203204
import org.apache.tsfile.write.schema.MeasurementSchema;
204205

205206
public class SessionPoolExample {
206-
private static SessionPool sessionPool;
207-
public static void main(String[] args) throws IoTDBConnectionException, StatementExecutionException {
207+
private static SessionPool sessionPool;
208+
public static void main(String[] args) throws IoTDBConnectionException, StatementExecutionException {
208209
// 1. init SessionPool
209210
constructSessionPool();
210211
// 2. execute insert data
211212
insertTabletExample();
212213
// 3. close SessionPool
213214
closeSessionPool();
214-
}
215+
}
215216

216-
private static void constructSessionPool() {
217+
private static void constructSessionPool() {
217218
// Using nodeUrls ensures that when one node goes down, other nodes are automatically connected to retry
218219
List<String> nodeUrls = new ArrayList<>();
219220
nodeUrls.add("127.0.0.1:6667");
220-
nodeUrls.add("127.0.0.1:6668");
221+
//nodeUrls.add("127.0.0.1:6668");
221222
sessionPool =
222223
new SessionPool.Builder()
223224
.nodeUrls(nodeUrls)
@@ -238,31 +239,31 @@ public class SessionPoolExample {
238239
*/
239240
// The schema of measurements of one device
240241
// only measurementId and data type in MeasurementSchema take effects in Tablet
241-
List<MeasurementSchema> schemaList = new ArrayList<>();
242+
List<IMeasurementSchema> schemaList = new ArrayList<>();
242243
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
243244
schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
244245
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
245246

246-
Tablet tablet = new Tablet("root.sg.d1", schemaList, 100);
247+
Tablet tablet = new Tablet("root.sg.d1",schemaList,100);
247248

248249
// Method 1 to add tablet data
249250
long timestamp = System.currentTimeMillis();
250251

251252
Random random = new Random();
252253
for (long row = 0; row < 100; row++) {
253-
int rowIndex = tablet.rowSize++;
254+
int rowIndex = tablet.getRowSize();
254255
tablet.addTimestamp(rowIndex, timestamp);
255256
for (int s = 0; s < 3; s++) {
256257
long value = random.nextLong();
257-
tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex, value);
258+
tablet.addValue(schemaList.get(s).getMeasurementName(), rowIndex, value);
258259
}
259-
if (tablet.rowSize == tablet.getMaxRowNumber()) {
260+
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
260261
sessionPool.insertTablet(tablet);
261262
tablet.reset();
262263
}
263264
timestamp++;
264265
}
265-
if (tablet.rowSize != 0) {
266+
if (tablet.getRowSize() != 0) {
266267
sessionPool.insertTablet(tablet);
267268
tablet.reset();
268269
}

0 commit comments

Comments
 (0)