Package com.alimama.mdrill.json

Examples of com.alimama.mdrill.json.JSONObject


      if(!s.startsWith("_sb="))
      {
        continue;
      }
      String json=decodeString(s.substring(4));
      return new JSONObject(json);
    }
    return new JSONObject();
  }
View Full Code Here


       if(s==null)
       {
         return null;
       }
       try{
         JSONObject obj= new JSONObject(s);
         if(obj.has(key))
         {
           return String.valueOf(obj.get(key));
         }
       }catch(Throwable e)
       {
         return null;
       }
View Full Code Here

      if(!s.startsWith("_sb="))
      {
        continue;
      }
      String json=decodeString(s.substring(4));
      return new JSONObject(json);
    }
    return new JSONObject();
  }
View Full Code Here

       if(s==null)
       {
         return null;
       }
       try{
         JSONObject obj= new JSONObject(s);
         if(obj.has(key))
         {
           return String.valueOf(obj.get(key));
         }
       }catch(Throwable e)
       {
         return null;
       }
View Full Code Here

        try {
          String strday=ColsDefine.formatDay.format(new Date(System.currentTimeMillis()-1000l*3600*24));
          String fqstr="[{\"thedate\":{\"operate\":1,\"value\":[\""+strday+"\"]}}]";
          String jsonstr=MdrillService.result("ods_quanjing_416_pc_pid", null, "0", "10000", fqstr, null, "putin_date,pid,url,count(*)", "putin_date,pid,url", "count(*)", "desc", null, null);
          LOG.info("fetch "+j+"@"+jsonstr);
          JSONObject jsonObj = new JSONObject(jsonstr);
          if(!jsonObj.getString("code").equals("1"))
          {
            sleep();
            continue;
          }
   
          JSONArray list=jsonObj.getJSONObject("data").getJSONArray("docs");

          if(list.length()==0)
          {
            sleep();
            continue;
          }
         
          for(int i=0;i<list.length();i++)
          {
            try {
              JSONObject item = list.getJSONObject(i);
              String delivey_date= String.valueOf(item.get("putin_date"));
              String url_lwfrom=ColsDefine.getName(String.valueOf(item.get("url")), "lwfrom");
              String adid = String.valueOf(url_lwfrom);
              String pid = String.valueOf(item.get("pid"));
              rtn.put(delivey_date+"@"+adid, pid);
            } catch (Exception e) {
              LOG.info("fetch parse error", e);
            }
          }
View Full Code Here

        try {
          String strday=ColsDefine.formatDay.format(new Date(System.currentTimeMillis()-1000l*3600*24));
          String fqstr="[{\"thedate\":{\"operate\":1,\"value\":[\""+strday+"\"]}}]";
          String jsonstr=MdrillService.result("ods_quanjing_416_wireless_pid", null, "0", "10000", fqstr, null, "putin_date,pid,lwfrom,count(*)", "putin_date,pid,lwfrom", "count(*)", "desc", null, null);
          LOG.info("fetch "+j+"@"+jsonstr);
          JSONObject jsonObj = new JSONObject(jsonstr);
          if(!jsonObj.getString("code").equals("1"))
          {
            sleep();
            continue;
          }
   
          JSONArray list=jsonObj.getJSONObject("data").getJSONArray("docs");

          if(list.length()==0)
          {
            sleep();
            continue;
          }
         
          for(int i=0;i<list.length();i++)
          {
            try {
              JSONObject item = list.getJSONObject(i);
              String delivey_date= String.valueOf(item.get("putin_date"));
              String adid = String.valueOf(item.get("lwfrom"));
              String pid = String.valueOf(item.get("pid"));
              rtn.put(delivey_date+"@"+adid, pid);
            } catch (Exception e) {
              LOG.info("fetch parse error", e);
            }
          }
View Full Code Here

  private static String[] getAllFields(JSONArray list) throws JSONException
  {
    HashSet<String> hashSet=new HashSet<String>();
    for(int i=0;i<list.length();i++)
    {
      JSONObject item=list.getJSONObject(i);
       Iterator  keys = item.keys();
            while (keys.hasNext()) {
              hashSet.add((String) keys.next());
            }
    }
   
View Full Code Here

        writeArrfHeader(ramwriter, fields);

        String maxThedate=null;
        for(int i=0;i<end;i++)
    {
      JSONObject item=list.getJSONObject(i);
       String joinl="";
          StringBuilder bl = new StringBuilder();
           for(String f:fields)
           {
             Object val=item.get(f);
             maxThedate=maxThedate(f,maxThedate, val);

             bl.append(joinl);
             bl.append(val);
             joinl=",";

             if(writeline&&lines.containsKey(f))
             {
               ArrayList<ArrayList<Object>> d=(ArrayList<ArrayList<Object>>) lines.get(f).get("data");
               ArrayList<Object> drow=new ArrayList<Object>();
               long t=fmt.parse(item.getString("thedate")).getTime();
               minmax.min=Math.min(minmax.min, t);
               minmax.max=Math.max(minmax.max, t);
               drow.add(0, t);
               drow.add(1, val);
               d.add(drow);
View Full Code Here

      if(groupby==null||!groupby.equals("thedate"))
      {
        rtna.put("code",0);
        rtna.put("msg","时间序列分析必须选择日期,且不能有其他维度");
        hb.stop();
        return new JSONObject(rtna).toString();
      }
     
    String rtn= MdrillService.result(projectName, null, "0", "100", queryStr, dist, fl, groupby, "thedate", "asc", leftjoin, null);
   
    JSONObject jsonObj = new JSONObject(rtn);
    if(!jsonObj.getString("code").equals("1"))
    {
      rtna.put("code",0);
      rtna.put("msg","服务器异常,请稍后再试");
      hb.stop();
      return new JSONObject(rtna).toString();
    }

    JSONArray list=jsonObj.getJSONObject("data").getJSONArray("docs");
    int presize=(list.length()/3)+1;
   
    if(list.length()<2)
    {
      rtna.put("code",0);
      rtna.put("msg","请至少选择2天的数据");
      hb.stop();
      return new JSONObject(rtna).toString();
    }
   
    String[] fields=getAllFields(list);
     HashMap<String,String> field2dimvalue=fieldToShowName(fl, dimvalue);

        StringBuilder numberfield = new StringBuilder();

       
    HashMap<String,HashMap<String,Object>> lines=setUpLines(numberfield,fields, isSingleY, field2dimvalue);

        int len=list.length();
        minMaxX minmax=new minMaxX();
    for(int i=10;i<len;i++)
    {
          makePre(lines, false, i, 1, minmax, fields, list, numberfield);
    }
        makePre(lines, true, len, presize, minmax, fields, list, numberfield);


   
 
        hb.stop();
      rtna.put("code", 1);
    rtna.put("data", lines);
    rtna.put("min", minmax.min);
    rtna.put("max", minmax.max);
    return new JSONObject(rtna).toString();
       
  }
View Full Code Here

        HashMap<String, String> rtn=new HashMap<String, String>();
        try {
          String fqstr="[{\"thedate\":{\"operate\":1,\"value\":[\"20140228\"]}}]";
          String jsonstr=MdrillService.result("dim_adpmp_bd_activity_d", null, "0", "10000", fqstr, null, "delivey_date,adid,pid,count(*)", "delivey_date,adid,pid", "count(*)", "desc", null, null);
          LOG.info("fetch "+j+"@"+jsonstr);
          JSONObject jsonObj = new JSONObject(jsonstr);
          if(!jsonObj.getString("code").equals("1"))
          {
            sleep();
            continue;
          }
   
          JSONArray list=jsonObj.getJSONObject("data").getJSONArray("docs");

          if(list.length()==0)
          {
            sleep();
            continue;
          }
         
          for(int i=0;i<list.length();i++)
          {
            try {
              JSONObject item = list.getJSONObject(i);
              String delivey_date= String.valueOf(item.get("delivey_date"));
              String adid = String.valueOf(item.get("adid"));
              String pid = String.valueOf(item.get("pid"));
              rtn.put(delivey_date+"@"+adid, pid);
            } catch (Exception e) {
              LOG.info("fetch parse error", e);
            }
          }
View Full Code Here

TOP

Related Classes of com.alimama.mdrill.json.JSONObject

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.