Package com.alimama.mdrill.json

Examples of com.alimama.mdrill.json.JSONArray


    return rtn;
  }
 
  private static String[] Json2Array(String j) throws JSONException
  {
      JSONArray jsonStr=new JSONArray(j.trim());
      ArrayList<String> rtn=new ArrayList<String>();
      for(int i=0;i<jsonStr.length();i++)
      {
        rtn.add(jsonStr.getString(i));
      }
     
      return rtn.toArray(new String[rtn.size()]);

  }
View Full Code Here


    }

   
    if (projectName.equals("fact_wirelesspv_clickcosteffect1_app_adhoc_d_1")) {
      projectName="fact_wirelesspv_clickcosteffect1_app_adhoc_d";
      JSONArray jsonStr=new JSONArray(queryStr.trim());
      JSONObject obj=new JSONObject();
      obj.put("key", "app_type");
      obj.put("operate", "1");
      obj.put("value", "1");
      jsonStr.put(obj);
      queryStr = WebServiceParams.query(jsonStr.toString());
    }
    if (projectName.equals("fact_wirelesspv_clickcosteffect1_app_adhoc_d_2")) {
      projectName="fact_wirelesspv_clickcosteffect1_app_adhoc_d";
      JSONArray jsonStr=new JSONArray(queryStr.trim());
      JSONObject obj=new JSONObject();
      obj.put("key", "app_type");
      obj.put("operate", "1");
      obj.put("value", "2");
      jsonStr.put(obj);
      queryStr = WebServiceParams.query(jsonStr.toString());
    }
    if (projectName.equals("fact_wirelesspv_clickcosteffect1_app_adhoc_d_3")) {
      projectName="fact_wirelesspv_clickcosteffect1_app_adhoc_d";
      JSONArray jsonStr=new JSONArray(queryStr.trim());
      JSONObject obj=new JSONObject();
      obj.put("key", "app_type");
      obj.put("operate", "1");
      obj.put("value", "3");
      jsonStr.put(obj);
      queryStr = WebServiceParams.query(jsonStr.toString());
    }
   
    if (projectName.equals("fact_wirelesspv_clickcosteffect1_app_adhoc_d_4")) {
      projectName="fact_wirelesspv_clickcosteffect1_app_adhoc_d";
      JSONArray jsonStr=new JSONArray(queryStr.trim());
      JSONObject obj=new JSONObject();
      obj.put("key", "app_type");
      obj.put("operate", "1");
      obj.put("value", "4");
      jsonStr.put(obj);
      queryStr = WebServiceParams.query(jsonStr.toString());
    }
   
   
 
 
View Full Code Here

      SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
      boolean isset=false;

      Long small=-1l;
      Long bigger=-1l;
      JSONArray jsonStr=new JSONArray(queryStr.trim());
      JSONArray jsonStr_new=new JSONArray();

      for(int j=0;j<jsonStr.length();j++)
      {
        JSONObject obj=jsonStr.getJSONObject(j);
        if(!obj.has("thedate"))
        {
          jsonStr_new.put(obj);
          continue;
        }
       
       

   
      }
     
      for(int j=0;j<jsonStr.length();j++)
      {
        JSONObject obj=jsonStr.getJSONObject(j);
        if(!obj.has("thedate"))
        {
          continue;
        }
       
       

      JSONObject thedate=obj.getJSONObject("thedate");
      Integer operate=Integer.parseInt(thedate.get("operate").toString());
      String[] val=WebServiceParams.parseFqValue(thedate.getString("value"), operate).split(",");
      if(operate==1 ||operate==5||operate==6||operate==7||operate==8||operate==9)//=,range
      {
        Long min=Long.MAX_VALUE;
        Long max=Long.MIN_VALUE;
            for(String day:val)
            {
              Date d=fmt.parse(day.replaceAll("-", ""));
              Long time=d.getTime();
              max=Math.max(max, time);
              min=Math.min(min, time);
              isset=true;
            }
            String[] days=getKmeans(min, max);
            for(String day:days)
            {
              rtn.add(day);
            }
            break;
           
      }
     
      if(operate==13||operate==3)//<,<=
      {
            for(String day:val)
            {
              Date d=fmt.parse(day.replaceAll("-", ""));
              Long time=d.getTime()+(operate==3?0:1);
              small=small>0?Math.min(small, time):time;
            }
      }
     
      if(operate==14||operate==4)//>,>=
      {
            for(String day:val)
            {
              Date d=fmt.parse(day.replaceAll("-", ""));
              Long time=d.getTime()-(operate==4?0:1);
              bigger=bigger>0?Math.max(bigger, time):time;
            }
      }
     
      if(bigger>0&&small>0)
      {
        isset=true;
         String[] days=getKmeans(small, bigger);
              for(String day:days)
              {
                rtn.add(day);
              }
            small=Long.MAX_VALUE;
          bigger=Long.MIN_VALUE;
          break;
      }
      
   
      }

 

      if(!isset)
      {
        throw new Exception("no thedate");
      }
 
      String[] rtnarr=new String[rtn.size()];
     
      KmeansQueryParse kmeans=new KmeansQueryParse();
      kmeans.days=rtn.toArray(rtnarr);
      kmeans.queryStr=jsonStr_new.toString();
      return kmeans;
    }
View Full Code Here

        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
        boolean isset=false;

        Long small=-1l;
        Long bigger=-1l;
        JSONArray jsonStr=new JSONArray(queryStr.trim());

        for(int j=0;j<jsonStr.length();j++)
        {
          JSONObject obj=jsonStr.getJSONObject(j);
          if(obj.has("thedate"))
          {
            JSONObject thedate=obj.getJSONObject("thedate");
            Integer operate=Integer.parseInt(thedate.get("operate").toString());
            String[] val=WebServiceParams.parseFqValue(thedate.getString("value"), operate).split(",");
View Full Code Here

          {
            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);
View Full Code Here

          {
            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) {
View Full Code Here

      BinaryExpression be = (BinaryExpression)ex;
      generateList(be.getLeftExpression(), linkList,parent);
      generateList(be.getRightExpression(), linkList,parent);
 
    }else if(ex instanceof Parenthesis){
      JSONArray sublist = new JSONArray();//{colname:{operate:1,value:xxxx}}
      JSONObject subQuery=new JSONObject();
      subQuery.put("subQuery", "1");
      subQuery.put("filter", "AND");
      subQuery.put("list", sublist);
      Expression exp = getExpressionWithoutParenthesis(ex);
View Full Code Here

  }
 
  private JSONArray toJSONArray(String str,String split)
  {
    String[] list=str.split(split);
    JSONArray rtn=new JSONArray();
    for(String s:list)
    {
      rtn.put(s.trim().replaceAll("^'", "").replaceAll("'$", ""));
    }
    return rtn;
  }
View Full Code Here

   
    JSONObject subitem=new JSONObject();
    String op=oe.getExp();
    String colname=oe.getColumnname();
    String val=String.valueOf(oe.getValue());
    JSONArray rtn=new JSONArray();
    rtn.put(val);
    subitem.put("value", rtn);
    if(op.equals("="))
    {
      subitem.put("operate", "1");
    }else if(op.equals("<>"))
View Full Code Here

    {
      String where=split[1].trim();
      CCJSqlParserManager pm = new CCJSqlParserManager();
      PlainSelect plainSelect =  (PlainSelect)((Select) pm.parse(new StringReader("select * from abc where "+where))).getSelectBody();
      Expression e  = getExpressionWithoutParenthesis(plainSelect.getWhere());
      JSONArray jsonObj = new JSONArray();//{colname:{operate:1,value:xxxx}}

      JSONObject subQuery=new JSONObject();
      subQuery.put("subQuery", "1");
      subQuery.put("filter", "AND");
      subQuery.put("list", jsonObj);
View Full Code Here

TOP

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

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.