summaryrefslogtreecommitdiff
path: root/src/main/Analyzor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/Analyzor.java')
-rw-r--r--src/main/Analyzor.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java
index 9e26c97..2589e66 100644
--- a/src/main/Analyzor.java
+++ b/src/main/Analyzor.java
@@ -255,6 +255,20 @@ public class Analyzor {
}
/**
+ * @return The number of rows that would be returned by the query.
+ */
+ private int getQuerySize(String query) throws SQLException {
+ PreparedStatement statement;
+ String countQuery = "WITH q AS (" + query + ") SELECT COUNT(*) FROM q";
+ statement = connection.prepareStatement(countQuery);
+ ResultSet result = statement.executeQuery();
+ result.next();
+ int count = result.getInt("count");
+ result.close();
+ return count;
+ }
+
+ /**
* Obtain the brands of select tweet texts.
*
* @param queryText The rows to select.
@@ -275,6 +289,11 @@ public class Analyzor {
if (queryText.isEmpty()) {
queryText = "SELECT tweetid, text FROM tweet";
}
+
+ // print expected count, this will increase the initial startup time
+ // (5s for 10M results), but will give an accurate ETA estimator
+ System.out.println("Expected query size: " + getQuerySize(queryText));
+
// allow the use of cursors for less memory usage
connection.setAutoCommit(false);
statement = connection.prepareStatement(queryText);