Package com.alimama.mdrill.jdbc

Examples of com.alimama.mdrill.jdbc.MdrillQueryResultSet


  public Metric getMetric(String tablename, String thedate) throws IOException{
    String sqlFormat=(String) conf.get("adhoc.metric.mdrill.sql."+tablename);
    Metric metric = null;
    String sql = String.format(sqlFormat, thedate);
    System.out.println("Higo SQL:" + sql);
    MdrillQueryResultSet rs;
    try {
      rs = (MdrillQueryResultSet) stmt.executeQuery(sql);
      if(rs.next()){
        metric = new Metric();
        metric.setThedate(thedate);
        metric.setType(1);
        metric.setTablename(tablename);
        metric.setLineCnt((long)Float.parseFloat(rs.getString(1)));
        metric.setImpression((long)Float.parseFloat(rs.getString(2)));
        metric.setFinClick((long)Float.parseFloat(rs.getString(3)));
        metric.setFinPrice(Float.parseFloat(rs.getString(4)));
        metric.setAlipayDirectNum((long)Float.parseFloat(rs.getString(5)));
        metric.setAlipayDirectAmt(Float.parseFloat(rs.getString(6)));
        metric.setAlipayIndirectNum((long)Float.parseFloat(rs.getString(7)));
        metric.setAlipayIndirectAmt(Float.parseFloat(rs.getString(8)));
      }
    } catch (SQLException e) {
      System.err.println("[" + sdf.format(new Date(System.currentTimeMillis())) + "] "
          + "Error when execute Higo SQL: "
          + sql);
View Full Code Here


        stmt.execute(sql);
        buff.append("执行完毕<br>\r\n");
        buff.append("<br>\r\n");
      }else{

        MdrillQueryResultSet res = null;
     
        res = (MdrillQueryResultSet) stmt.executeQuery(sql);
        buff.append("totalRecords:"+res.getTotal());
        buff.append("<br>\r\n");
        buff.append("<table border=1><tr>");
        List<String> colsNames = res.getColumnNames();
        for (int i = 0; i < colsNames.size(); i++) {
          buff.append("<td>");
            buff.append(colsNames.get(i));
            buff.append("</td>");
        }
        buff.append("</tr>");
        while (res.next()) {
          buff.append("<tr>");
            for (int i = 0; i < colsNames.size(); i++) {
              buff.append("<td>");
          buff.append(res.getString(colsNames.get(i)));
          buff.append("</td>");
            }
            buff.append("</tr>");
        }
        con.close();
View Full Code Here

    Connection con = DriverManager.getConnection("jdbc:mdrill://adhoc7.kgb.cm6:9999", "", "");

    Statement stmt = con.createStatement();
   

      MdrillQueryResultSet res = null;
   
      res = (MdrillQueryResultSet) stmt.executeQuery(sql);
 
      while (res.next()) {
        String thedate=res.getString("thedate");
        String pid=res.getString("pid");
        int index=dayIndex.get(thedate);
       
        PidStat stat=rtn.get(pid);
        if(stat==null)
        {
          stat=new PidStat();
          stat.start=start;
          stat.end=end;
          stat.dayList=dayList;
          stat.p4pprice=new double[dayList.length];
          stat.p4pclick=new double[dayList.length];
          stat.apv=new double[dayList.length];
          stat.p4ppv=new double[dayList.length];
          stat.aclick=new double[dayList.length];
          rtn.put(pid, stat);
        }
       
        stat.p4pprice[index]=Double.parseDouble(res.getString("p4pprice"));
        stat.p4pclick[index]=Double.parseDouble(res.getString("p4pclick"));
        stat.apv[index]=Double.parseDouble(res.getString("apv"));
        stat.p4ppv[index]=Double.parseDouble(res.getString("p4ppv"));
        stat.aclick[index]=Double.parseDouble(res.getString("p4pprice"));
      }
      con.close();
     
      return rtn;
  }
View Full Code Here

      Connection con = DriverManager.getConnection(
          "jdbc:mdrill://adhoc7.kgb.cm6:9999", "", "");

      Statement stmt = con.createStatement();

      MdrillQueryResultSet res = null;

      res = (MdrillQueryResultSet) stmt.executeQuery(sql);

      while (res.next()) {
        String thedate = res.getString("thedate");
        String pid = res.getString("pid");
        int index = dayIndex.get(thedate);

        PidStat stat = rtn.get(pid);
        if (stat == null) {
          stat = new PidStat();
          stat.start = start;
          stat.end = end;
          stat.dayList = dayList;
          stat.p4pclick = new double[dayList.length];
          stat.p4ppv = new double[dayList.length];
          rtn.put(pid, stat);
        }

        stat.p4ppv[index] = Double
            .parseDouble(res.getString("records"));
      }
      con.close();

    }
   
    {

      String sql = "select " + " thedate,pid,sum(records) as records "
          + " from tanx_click where thedate in ('" + dayList[0]
          + "','" + dayList[1] + "','" + dayList[2] + "','"
          + dayList[3] + "','" + dayList[4] + "') " + " and pid in ("
          + pidliststr + ") and " + minfilter
          + " group by thedate,pid limit 0,8000 ";

      Connection con = DriverManager.getConnection(
          "jdbc:mdrill://adhoc7.kgb.cm6:9999", "", "");

      Statement stmt = con.createStatement();

      MdrillQueryResultSet res = null;

      res = (MdrillQueryResultSet) stmt.executeQuery(sql);

      while (res.next()) {
        String thedate = res.getString("thedate");
        String pid = res.getString("pid");
        int index = dayIndex.get(thedate);

        PidStat stat = rtn.get(pid);
        if (stat == null) {
          stat = new PidStat();
          stat.start = start;
          stat.end = end;
          stat.dayList = dayList;
          stat.p4pclick = new double[dayList.length];
          stat.p4ppv = new double[dayList.length];
          rtn.put(pid, stat);
        }

        stat.p4pclick[index] = Double.parseDouble(res
            .getString("records"));
      }
      con.close();

    }
View Full Code Here

      Connection con = DriverManager.getConnection(
          "jdbc:mdrill://adhoc7.kgb.cm6:9999", "", "");

      Statement stmt = con.createStatement();

      MdrillQueryResultSet res = null;

      res = (MdrillQueryResultSet) stmt.executeQuery(sql);

      while (res.next()) {
        String thedate = res.getString("thedate");
        String pid = res.getString("pid");
        int index = dayIndex.get(thedate);

        PidStat stat = rtn.get(pid);
        if (stat == null) {
          stat = new PidStat();
          stat.start = start;
          stat.end = end;
          stat.dayList = dayList;
          stat.p4pclick = new double[dayList.length];
          stat.p4ppv = new double[dayList.length];
          rtn.put(pid, stat);
        }

        stat.p4ppv[index] = Double
            .parseDouble(res.getString("records"));
      }
      con.close();

    }
   
    {

      String sql = "select " + " thedate,pid,sum(records) as records "
          + " from tanx_click where thedate in ('" + dayList[0]
          + "','" + dayList[1] + "','" + dayList[2] + "','"
          + dayList[3] + "','" + dayList[4] + "') " + " and pid in ("
          + pidliststr + ") and " + minfilter
          + " group by thedate,pid limit 0,8000 ";

      Connection con = DriverManager.getConnection(
          "jdbc:mdrill://adhoc7.kgb.cm6:9999", "", "");

      Statement stmt = con.createStatement();

      MdrillQueryResultSet res = null;

      res = (MdrillQueryResultSet) stmt.executeQuery(sql);

      while (res.next()) {
        String thedate = res.getString("thedate");
        String pid = res.getString("pid");
        int index = dayIndex.get(thedate);

        PidStat stat = rtn.get(pid);
        if (stat == null) {
          stat = new PidStat();
          stat.start = start;
          stat.end = end;
          stat.dayList = dayList;
          stat.p4pclick = new double[dayList.length];
          stat.p4ppv = new double[dayList.length];
          rtn.put(pid, stat);
        }

        stat.p4pclick[index] = Double.parseDouble(res
            .getString("records"));
      }
      con.close();

    }
View Full Code Here

    Connection con = DriverManager.getConnection("jdbc:mdrill://adhoc7.kgb.cm6:9999", "", "");

    Statement stmt = con.createStatement();
   

      MdrillQueryResultSet res = null;
   
      res = (MdrillQueryResultSet) stmt.executeQuery(sql);
 
      while (res.next()) {
        String thedate=res.getString("thedate");
        String pid=res.getString("pid");
        int index=dayIndex.get(thedate);
       
        PidStat stat=rtn.get(pid);
        if(stat==null)
        {
          stat=new PidStat();
          stat.start=start;
          stat.end=end;
          stat.dayList=dayList;
          stat.p4pprice=new double[dayList.length];
          stat.p4pclick=new double[dayList.length];
          stat.apv=new double[dayList.length];
          stat.p4ppv=new double[dayList.length];
          stat.aclick=new double[dayList.length];
          rtn.put(pid, stat);
        }
       
        stat.p4pprice[index]=Double.parseDouble(res.getString("p4pprice"));
        stat.p4pclick[index]=Double.parseDouble(res.getString("p4pclick"));
        stat.apv[index]=Double.parseDouble(res.getString("apv"));
        stat.p4ppv[index]=Double.parseDouble(res.getString("p4ppv"));
        stat.aclick[index]=Double.parseDouble(res.getString("p4pprice"));
      }
      con.close();
     
      return rtn;
  }
View Full Code Here

TOP

Related Classes of com.alimama.mdrill.jdbc.MdrillQueryResultSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.