未验证 提交 82988f82 编写于 作者: B Bo Ding 提交者: GitHub

docs: fast write example for java and python (#15171)

* docs: monitor numberOfTable in FaskWriteExample.java

* docs: add note to python example
上级 3027c06d
...@@ -44,4 +44,20 @@ public class DataBaseMonitor { ...@@ -44,4 +44,20 @@ public class DataBaseMonitor {
} }
return null; return null;
} }
/**
* show test.stables;
*
* name | created_time | columns | tags | tables |
* ============================================================================================
* meters | 2022-07-20 08:39:30.902 | 4 | 2 | 620000 |
*/
public Long getTableCount() throws SQLException {
if (!stmt.isClosed()) {
ResultSet result = stmt.executeQuery("show test.stables");
result.next();
return result.getLong(5);
}
return null;
}
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ import java.util.concurrent.BlockingQueue; ...@@ -13,7 +13,7 @@ import java.util.concurrent.BlockingQueue;
public class FastWriteExample { public class FastWriteExample {
final static Logger logger = LoggerFactory.getLogger(FastWriteExample.class); final static Logger logger = LoggerFactory.getLogger(FastWriteExample.class);
final static int taskQueueCapacity = 10000000; final static int taskQueueCapacity = 1000000;
final static List<BlockingQueue<String>> taskQueues = new ArrayList<>(); final static List<BlockingQueue<String>> taskQueues = new ArrayList<>();
final static List<ReadTask> readTasks = new ArrayList<>(); final static List<ReadTask> readTasks = new ArrayList<>();
final static List<WriteTask> writeTasks = new ArrayList<>(); final static List<WriteTask> writeTasks = new ArrayList<>();
...@@ -61,8 +61,9 @@ public class FastWriteExample { ...@@ -61,8 +61,9 @@ public class FastWriteExample {
long lastCount = 0; long lastCount = 0;
while (true) { while (true) {
Thread.sleep(10000); Thread.sleep(10000);
long numberOfTable = databaseMonitor.getTableCount();
long count = databaseMonitor.count(); long count = databaseMonitor.count();
logger.info("count={} speed={}", count, (count - lastCount) / 10); logger.info("numberOfTable={} count={} speed={}", numberOfTable, count, (count - lastCount) / 10);
lastCount = count; lastCount = count;
} }
} }
......
...@@ -428,6 +428,12 @@ SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提 ...@@ -428,6 +428,12 @@ SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提
</details> </details>
:::note
使用 Python 连接器多进程连接 TDengine 的时候,有一个限制:不能在父进程中建立连接,所有连接只能在子进程中创建。
如果在父进程中创建连接,子进程再创建连接就会一直阻塞。这是个已知问题。
:::
</TabItem> </TabItem>
</Tabs> </Tabs>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册