This is an automated email from the ASF dual-hosted git repository.
critas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iotdb-docs.git
The following commit(s) were added to refs/heads/main by this push:
new 8c0fad15 update tablet functions (#839)
8c0fad15 is described below
commit 8c0fad158fb0b7d9e544e12b18d9266112ebc193
Author: leto-b <[email protected]>
AuthorDate: Thu Aug 28 17:04:32 2025 +0800
update tablet functions (#839)
---
.../Master/Tree/API/Programming-Java-Native-API.md | 23 +++++++++++-----------
.../latest/API/Programming-Java-Native-API.md | 23 +++++++++++-----------
.../Master/Tree/API/Programming-Java-Native-API.md | 23 +++++++++++-----------
.../latest/API/Programming-Java-Native-API.md | 23 +++++++++++-----------
4 files changed, 48 insertions(+), 44 deletions(-)
diff --git a/src/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
b/src/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
index 347493e0..b191fe31 100644
--- a/src/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
+++ b/src/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
@@ -202,24 +202,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.pool.SessionPool;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
public class SessionPoolExample {
- private static SessionPool sessionPool;
- public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
+ private static SessionPool sessionPool;
+ public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
// 1. init SessionPool
constructSessionPool();
// 2. execute insert data
insertTabletExample();
// 3. close SessionPool
closeSessionPool();
- }
+ }
- private static void constructSessionPool() {
+ private static void constructSessionPool() {
// Using nodeUrls ensures that when one node goes down, other nodes
are automatically connected to retry
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("127.0.0.1:6667");
- nodeUrls.add("127.0.0.1:6668");
+ //nodeUrls.add("127.0.0.1:6668");
sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
@@ -240,31 +241,31 @@ public class SessionPoolExample {
*/
// The schema of measurements of one device
// only measurementId and data type in MeasurementSchema take effects
in Tablet
- List<MeasurementSchema> schemaList = new ArrayList<>();
+ List<IMeasurementSchema> schemaList = new ArrayList<>();
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
- Tablet tablet = new Tablet("root.sg.d1", schemaList, 100);
+ Tablet tablet = new Tablet("root.sg.d1",schemaList,100);
// Method 1 to add tablet data
long timestamp = System.currentTimeMillis();
Random random = new Random();
for (long row = 0; row < 100; row++) {
- int rowIndex = tablet.rowSize++;
+ int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, timestamp);
for (int s = 0; s < 3; s++) {
long value = random.nextLong();
- tablet.addValue(schemaList.get(s).getMeasurementId(),
rowIndex, value);
+ tablet.addValue(schemaList.get(s).getMeasurementName(),
rowIndex, value);
}
- if (tablet.rowSize == tablet.getMaxRowNumber()) {
+ if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
timestamp++;
}
- if (tablet.rowSize != 0) {
+ if (tablet.getRowSize() != 0) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
diff --git a/src/UserGuide/latest/API/Programming-Java-Native-API.md
b/src/UserGuide/latest/API/Programming-Java-Native-API.md
index 7ef45e59..245a4972 100644
--- a/src/UserGuide/latest/API/Programming-Java-Native-API.md
+++ b/src/UserGuide/latest/API/Programming-Java-Native-API.md
@@ -202,24 +202,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.pool.SessionPool;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
public class SessionPoolExample {
- private static SessionPool sessionPool;
- public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
+ private static SessionPool sessionPool;
+ public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
// 1. init SessionPool
constructSessionPool();
// 2. execute insert data
insertTabletExample();
// 3. close SessionPool
closeSessionPool();
- }
+ }
- private static void constructSessionPool() {
+ private static void constructSessionPool() {
// Using nodeUrls ensures that when one node goes down, other nodes
are automatically connected to retry
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("127.0.0.1:6667");
- nodeUrls.add("127.0.0.1:6668");
+ //nodeUrls.add("127.0.0.1:6668");
sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
@@ -240,31 +241,31 @@ public class SessionPoolExample {
*/
// The schema of measurements of one device
// only measurementId and data type in MeasurementSchema take effects
in Tablet
- List<MeasurementSchema> schemaList = new ArrayList<>();
+ List<IMeasurementSchema> schemaList = new ArrayList<>();
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
- Tablet tablet = new Tablet("root.sg.d1", schemaList, 100);
+ Tablet tablet = new Tablet("root.sg.d1",schemaList,100);
// Method 1 to add tablet data
long timestamp = System.currentTimeMillis();
Random random = new Random();
for (long row = 0; row < 100; row++) {
- int rowIndex = tablet.rowSize++;
+ int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, timestamp);
for (int s = 0; s < 3; s++) {
long value = random.nextLong();
- tablet.addValue(schemaList.get(s).getMeasurementId(),
rowIndex, value);
+ tablet.addValue(schemaList.get(s).getMeasurementName(),
rowIndex, value);
}
- if (tablet.rowSize == tablet.getMaxRowNumber()) {
+ if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
timestamp++;
}
- if (tablet.rowSize != 0) {
+ if (tablet.getRowSize() != 0) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
diff --git a/src/zh/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
b/src/zh/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
index e0e65cf2..c7673d12 100644
--- a/src/zh/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
+++ b/src/zh/UserGuide/Master/Tree/API/Programming-Java-Native-API.md
@@ -200,24 +200,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.pool.SessionPool;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
public class SessionPoolExample {
- private static SessionPool sessionPool;
- public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
+ private static SessionPool sessionPool;
+ public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
// 1. init SessionPool
constructSessionPool();
// 2. execute insert data
insertTabletExample();
// 3. close SessionPool
closeSessionPool();
- }
+ }
- private static void constructSessionPool() {
+ private static void constructSessionPool() {
// Using nodeUrls ensures that when one node goes down, other nodes
are automatically connected to retry
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("127.0.0.1:6667");
- nodeUrls.add("127.0.0.1:6668");
+ //nodeUrls.add("127.0.0.1:6668");
sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
@@ -238,31 +239,31 @@ public class SessionPoolExample {
*/
// The schema of measurements of one device
// only measurementId and data type in MeasurementSchema take effects
in Tablet
- List<MeasurementSchema> schemaList = new ArrayList<>();
+ List<IMeasurementSchema> schemaList = new ArrayList<>();
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
- Tablet tablet = new Tablet("root.sg.d1", schemaList, 100);
+ Tablet tablet = new Tablet("root.sg.d1",schemaList,100);
// Method 1 to add tablet data
long timestamp = System.currentTimeMillis();
Random random = new Random();
for (long row = 0; row < 100; row++) {
- int rowIndex = tablet.rowSize++;
+ int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, timestamp);
for (int s = 0; s < 3; s++) {
long value = random.nextLong();
- tablet.addValue(schemaList.get(s).getMeasurementId(),
rowIndex, value);
+ tablet.addValue(schemaList.get(s).getMeasurementName(),
rowIndex, value);
}
- if (tablet.rowSize == tablet.getMaxRowNumber()) {
+ if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
timestamp++;
}
- if (tablet.rowSize != 0) {
+ if (tablet.getRowSize() != 0) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
diff --git a/src/zh/UserGuide/latest/API/Programming-Java-Native-API.md
b/src/zh/UserGuide/latest/API/Programming-Java-Native-API.md
index 7935c438..3c7b3a40 100644
--- a/src/zh/UserGuide/latest/API/Programming-Java-Native-API.md
+++ b/src/zh/UserGuide/latest/API/Programming-Java-Native-API.md
@@ -200,24 +200,25 @@ import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.pool.SessionPool;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
public class SessionPoolExample {
- private static SessionPool sessionPool;
- public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
+ private static SessionPool sessionPool;
+ public static void main(String[] args) throws IoTDBConnectionException,
StatementExecutionException {
// 1. init SessionPool
constructSessionPool();
// 2. execute insert data
insertTabletExample();
// 3. close SessionPool
closeSessionPool();
- }
+ }
- private static void constructSessionPool() {
+ private static void constructSessionPool() {
// Using nodeUrls ensures that when one node goes down, other nodes
are automatically connected to retry
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("127.0.0.1:6667");
- nodeUrls.add("127.0.0.1:6668");
+ //nodeUrls.add("127.0.0.1:6668");
sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
@@ -238,31 +239,31 @@ public class SessionPoolExample {
*/
// The schema of measurements of one device
// only measurementId and data type in MeasurementSchema take effects
in Tablet
- List<MeasurementSchema> schemaList = new ArrayList<>();
+ List<IMeasurementSchema> schemaList = new ArrayList<>();
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
- Tablet tablet = new Tablet("root.sg.d1", schemaList, 100);
+ Tablet tablet = new Tablet("root.sg.d1",schemaList,100);
// Method 1 to add tablet data
long timestamp = System.currentTimeMillis();
Random random = new Random();
for (long row = 0; row < 100; row++) {
- int rowIndex = tablet.rowSize++;
+ int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, timestamp);
for (int s = 0; s < 3; s++) {
long value = random.nextLong();
- tablet.addValue(schemaList.get(s).getMeasurementId(),
rowIndex, value);
+ tablet.addValue(schemaList.get(s).getMeasurementName(),
rowIndex, value);
}
- if (tablet.rowSize == tablet.getMaxRowNumber()) {
+ if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
sessionPool.insertTablet(tablet);
tablet.reset();
}
timestamp++;
}
- if (tablet.rowSize != 0) {
+ if (tablet.getRowSize() != 0) {
sessionPool.insertTablet(tablet);
tablet.reset();
}