From d0af74e97479346870a9da5000fbc4e832dab376 Mon Sep 17 00:00:00 2001 From: Yu Sun Date: Fri, 7 Oct 2022 19:54:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(ENodeConfigure):dimension=E8=A6=81=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E4=B8=80=E4=B8=AA=E4=B8=AA=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EdgeManager/EDataCapture/ENodeConfigure.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/EdgeManager/EDataCapture/ENodeConfigure.php b/EdgeManager/EDataCapture/ENodeConfigure.php index 9297714..e2c6257 100644 --- a/EdgeManager/EDataCapture/ENodeConfigure.php +++ b/EdgeManager/EDataCapture/ENodeConfigure.php @@ -63,10 +63,14 @@ class ENodeConfigure { )); if (!in_array($table_name, pg_fetch_all_columns($table_exists, 1))) { $res[] = $node_count = pg_query($this -> dbconn, "SELECT COUNT(*) from timescaledb_information.data_nodes"); - if (intval(pg_fetch_assoc($node_count)['count']) === 0) { + $node_count = intval(pg_fetch_assoc($node_count)['count']); + if ($node_count === 0) { $res[] = pg_query($this -> dbconn, sprintf("SELECT create_hypertable('\"%s\"', 'capture_time')", $table_name)); } else { - $res[] = pg_query($this -> dbconn, sprintf("SELECT create_distributed_hypertable('\"%s\"', 'capture_time', 'code', 'device_code', 'parent_device_code', 'batch')", $table_name)); + $res[] = pg_query($this -> dbconn, sprintf("SELECT create_distributed_hypertable('\"%s\"', 'capture_time', 'code')", $table_name)); + $res[] = pg_query($this -> dbconn, sprintf("add_dimension('\"%s\"', 'device_code', number_partitions => %s)", $node_count)); + $res[] = pg_query($this -> dbconn, sprintf("add_dimension('\"%s\"', 'parent_device_code', number_partitions => %s)", $node_count)); + $res[] = pg_query($this -> dbconn, sprintf("add_dimension('\"%s\"', 'batch', number_partitions => %s)", $node_count)); } $res[] = pg_query($this -> dbconn, sprintf(