You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2021/05/03 16:38:43 UTC

[GitHub] [phoenix] yanxinyi commented on a change in pull request #1160: Implement TableMetricsManager class and its associated functions for select. upsert and Delete Queries

yanxinyi commented on a change in pull request #1160:
URL: https://github.com/apache/phoenix/pull/1160#discussion_r625213175



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
##########
@@ -275,26 +325,72 @@ private boolean verifyMetricsFromSinkOnce(Map<String, Long> expectedMetrics) {
         return true;
     }
 
-    private static void createTableAndInsertValues(String tableName,
-            boolean resetGlobalMetricsAfterTableCreate) throws SQLException {
-        String ddl = String.format("CREATE TABLE %s (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)",
-                tableName);
-        try (Connection conn = DriverManager.getConnection(getUrl());
-                Statement stmt = conn.createStatement()) {
-            stmt.execute(ddl);
-            if (resetGlobalMetricsAfterTableCreate) {
-                resetGlobalMetrics();
-            }
-            // executing 10 upserts/mutations.
-            String dml = String.format("UPSERT INTO %s VALUES (?, ?)", tableName);
-            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
-                for (int i = 1; i <= 10; i++) {
-                    prepStmt.setString(1, "key" + i);
-                    prepStmt.setString(2, "value" + i);
-                    prepStmt.executeUpdate();
+    static void createTableAndInsertValues(String tableName,
+            boolean resetGlobalMetricsAfterTableCreate, boolean resetTableMetricsAfterTableCreate,
+            int numRows, boolean commit, Connection conn, boolean batchUpserts) throws SQLException {
+
+        try (Statement stmt = conn.createStatement()) {
+            stmt.execute(String.format(DDL, tableName));
+        }
+        conn.commit();
+        if (resetGlobalMetricsAfterTableCreate) {
+            resetGlobalMetrics();
+        }
+
+        if (resetTableMetricsAfterTableCreate) {
+            PhoenixRuntime.clearTableLevelMetrics();
+        }
+        // executing upserts/mutations.
+        try (PreparedStatement stmt = conn.prepareStatement(
+                String.format(UPSERT_VALUES_DML, tableName))) {
+            for (int i = 1; i <= numRows; i++) {
+                stmt.setString(1, "keyA" + i);

Review comment:
       nit: can you make those values as predeinfed? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org