@Override protected final String[] runDataTask() throws Exception { prepareInputs(); result = new Q18ResultRanking(); long startTime = System.currentTimeMillis(); for (int i = 0; i < ordersPartitionCount; ++i) { LOG.info("processing.. " + i + "/" + ordersPartitionCount); processPartition(i); } long endTime = System.currentTimeMillis(); LOG.info("total processPartition() time: " + (endTime - startTime) + "ms"); LOG.info("sub-ranking:" + result); // TODO : use outputToLocalTmpFile. // serialize the sub-ranking to a file VirtualFile tmpFolder = new LocalVirtualFile(context.localLvfsTmpDir); if (!tmpFolder.exists()) { tmpFolder.mkdirs(); } assert (tmpFolder.exists()); String filename = "tmp_subrank_" + Math.abs(new Random(System.nanoTime()).nextInt()); VirtualFile subrankFile = tmpFolder.getChildFile(filename); VirtualFileOutputStream out = subrankFile.getOutputStream(); DataOutputStream dataOut = new DataOutputStream(out); result.write(dataOut); dataOut.flush(); dataOut.close(); LOG.info("wrote sub-ranking to " + subrankFile.getAbsolutePath()); return new String[] {subrankFile.getAbsolutePath()}; }
private void addRanking( int custkey, long orderkey, long orderdate, double totalprice, double sumquantity) { Q18Result tuple = new Q18Result(); tuple.C_CUSTKEY = custkey; tuple.O_ORDERKEY = orderkey; tuple.O_ORDERDATE = orderdate; tuple.O_TOTALPRICE = totalprice; tuple.SUM_L_QUANTITY = sumquantity; result.add(tuple); }
private boolean willBeRanked(long orderkey, long orderdate, double totalprice) { return result.willBeRanked(orderkey, orderdate, totalprice); }