- ResultSet rs = ps.executeQuery();\r
- PrintWriter os = new PrintWriter(outfile);\r
- os.println("recordid,feedid,uri,size,min,max,avg,fanout");\r
- Counters c = null;\r
- while (rs.next()) {\r
- long etime = rs.getLong("EVENT_TIME");\r
- String type = rs.getString("TYPE");\r
- String id = rs.getString("PUBLISH_ID");\r
- String fid = rs.getString("FEED_FILEID");\r
- int feed = rs.getInt("FEEDID");\r
- long clen = rs.getLong("CONTENT_LENGTH");\r
- if (c != null && !id.equals(c.id)) {\r
- String line = id + "," + c.toString();\r
- os.println(line);\r
- c = null;\r
+ try(ResultSet rs = ps.executeQuery()) {\r
+ try(PrintWriter os = new PrintWriter(outfile)) {\r
+ os.println("recordid,feedid,uri,size,min,max,avg,fanout");\r
+ Counters c = null;\r
+ while (rs.next()) {\r
+ long etime = rs.getLong("EVENT_TIME");\r
+ String type = rs.getString("TYPE");\r
+ String id = rs.getString("PUBLISH_ID");\r
+ String fid = rs.getString("FEED_FILEID");\r
+ int feed = rs.getInt("FEEDID");\r
+ long clen = rs.getLong("CONTENT_LENGTH");\r
+ if (c != null && !id.equals(c.id)) {\r
+ String line = id + "," + c.toString();\r
+ os.println(line);\r
+ c = null;\r
+ }\r
+ if (c == null) {\r
+ c = new Counters(id, feed, clen, fid);\r
+ }\r
+ if (feed != c.feedid)\r
+ System.err.println("Feed ID mismatch, " + feed + " <=> " + c.feedid);\r
+ if (clen != c.clen)\r
+ System.err.println("Cont Len mismatch, " + clen + " <=> " + c.clen);\r
+ c.addEvent(type, etime);\r
+ }\r