public class InsertAccessLog { public static void main(String[] args) throws Exception { // Take the access log file name from the first command-line argument String filename = args[0]; // Split up the giant AccessLog file treating // each <req> element as its own subdocument. String splitElement = "req"; // Create an instance of the document handler. Commit every 100 LogEntryInsertHandler dochandler = new LogEntryInsertHandler(Examples.getConnection(),100); // Create a XMLDocumentSplitter XMLDocumentSplitter xds = new XMLDocumentSplitter(dochandler); long start = System.currentTimeMillis(); // Tell the splitter to split based on the splitElement 'req' xds.split(URLUtils.newURL(filename),splitElement); long end = System.currentTimeMillis(); long rows = dochandler.getRowsHandled(); System.out.println("Inserted "+dochandler.getRowsHandled()+" rows..."+ "in " + (end-start)+"ms." + " (" + ((end-start)/rows)+" ms. per row)"); } } |