hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1073765 - in /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc: JDBCStatsAggregator.java JDBCStatsPublisher.java
Date Wed, 23 Feb 2011 15:04:00 GMT
Author: namit
Date: Wed Feb 23 15:04:00 2011
New Revision: 1073765

URL: http://svn.apache.org/viewvc?rev=1073765&view=rev
Log:
HIVE-2000 adding comments to Hive Stats JDBC queries
(Ning Zhang via namit)


Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java?rev=1073765&r1=1073764&r2=1073765&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsAggregator.java Wed
Feb 23 15:04:00 2011
@@ -38,6 +38,7 @@ public class JDBCStatsAggregator impleme
   private Configuration hiveconf;
   private final Log LOG = LogFactory.getLog(this.getClass().getName());
   private int timeout = 30;
+  private final String comment = "Hive stats aggregation: " + this.getClass().getName();
 
   public boolean connect(Configuration hiveconf) {
     try {
@@ -72,7 +73,8 @@ public class JDBCStatsAggregator impleme
       Statement stmt = conn.createStatement();
       stmt.setQueryTimeout(timeout);
       String select =
-        "SELECT SUM" + "(" + JDBCStatsSetupConstants.PART_STAT_ROW_COUNT_COLUMN_NAME + ")"
+
+        "SELECT /* " + comment + " */ " +
+        " SUM(" + JDBCStatsSetupConstants.PART_STAT_ROW_COUNT_COLUMN_NAME + ")" +
         " FROM " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
         " WHERE " + JDBCStatsSetupConstants.PART_STAT_ID_COLUMN_NAME + " LIKE '" + fileID
+ "%'";
 
@@ -94,7 +96,8 @@ public class JDBCStatsAggregator impleme
           through a separate method which the developer has to call it manually in the code.
        */
       String delete =
-        "DELETE FROM " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
+        "DELETE /* " + comment + " */ " +
+        " FROM " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
         " WHERE " + JDBCStatsSetupConstants.PART_STAT_ID_COLUMN_NAME + " LIKE '" + fileID
+ "%'";
       stmt.executeUpdate(delete);
       stmt.close();
@@ -138,7 +141,8 @@ public class JDBCStatsAggregator impleme
       Statement stmt = conn.createStatement();
 
       String delete =
-        "DELETE FROM " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
+        "DELETE /* " + comment + " */ " +
+        " FROM " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
         " WHERE " + JDBCStatsSetupConstants.PART_STAT_ID_COLUMN_NAME + " LIKE '" + rowID
+ "%'";
       stmt.executeUpdate(delete);
       stmt.close();

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java?rev=1073765&r1=1073764&r2=1073765&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java Wed
Feb 23 15:04:00 2011
@@ -41,6 +41,9 @@ public class JDBCStatsPublisher implemen
   private final Log LOG = LogFactory.getLog(this.getClass().getName());
   private PreparedStatement selStmt, updStmt, insStmt;
   private int timeout = 30; // default timeout in sec. for JDBC connection and statements
+  // SQL comment that identifies where the SQL statement comes from
+  private final String comment = "Hive stats publishing: " + this.getClass().getName();
+
 
   public JDBCStatsPublisher() {
     selStmt = updStmt = insStmt = null;
@@ -58,17 +61,17 @@ public class JDBCStatsPublisher implemen
 
       // prepare the SELECT/UPDATE/INSERT statements
       String select =
-        "SELECT " + JDBCStatsSetupConstants.PART_STAT_ROW_COUNT_COLUMN_NAME +
+        "SELECT /* " + comment + " */ " + JDBCStatsSetupConstants.PART_STAT_ROW_COUNT_COLUMN_NAME
+
         " FROM " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
         " WHERE " + JDBCStatsSetupConstants.PART_STAT_ID_COLUMN_NAME + " = ?";
 
       String update =
-        "UPDATE " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
+        "UPDATE /* " + comment + " */ "+ JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
         " SET " +  JDBCStatsSetupConstants.PART_STAT_ROW_COUNT_COLUMN_NAME + "= ? " +
         " WHERE " + JDBCStatsSetupConstants.PART_STAT_ID_COLUMN_NAME + " = ?";
 
       String insert =
-        "INSERT INTO " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME +
+        "INSERT INTO /* " + comment + " */ " + JDBCStatsSetupConstants.PART_STAT_TABLE_NAME
+
         " VALUES (?, ?)";
 
       selStmt = conn.prepareStatement(select);



Mime
View raw message