Package org.ektorp

Examples of org.ektorp.ViewResult


    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
   
    System.out.println("getOrdersPerCountry");
    System.out.println("times");
    /*for(int i=0;i<10;++i){
      long st = System.nanoTime();
      result = or.getOrdersPerCountry();
      System.out.print(((System.nanoTime()-st)/1000000.0)+";");
    }*/
    result = iterate(result,or);
   
    System.out.println("\n");
    for(ViewResult.Row row : result.getRows()) {
      System.out.println("Country: "+row.getKey()+", Completed Orders: "+row.getValue());
   
   
  }
View Full Code Here


    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
   
    System.out.println("getAvgUnitPricePerShipper");
    System.out.println("times");
    for(int i=0;i<10;++i){
      long st = System.nanoTime();
      result = or.getAvgUnitPricePerShipper();
      System.out.print(((System.nanoTime()-st)/1000000.0)+";");
    }
    System.out.println();
    for(ViewResult.Row r : result.getRows()){
      JsonNode key = r.getKeyAsNode();
      JsonNode val = r.getValueAsNode();
     
      System.out.println("Shipper id="+key.get(0)+", year="+key.get(1)+", avgUnitPrice="+val.get(0));
   
View Full Code Here

    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
   
    System.out.println("getValueByWeek");
    System.out.println("times");
    for(int i=0;i<10;++i){
      long st = System.nanoTime();
      result = or.valueByWeekDay();
      System.out.print(((System.nanoTime()-st)/1000000.0)+";");
    }

    System.out.println("\n");
    for(ViewResult.Row r : result.getRows()){
      JsonNode key = r.getKeyAsNode();
      JsonNode val = r.getValueAsNode();     
      System.out.println("WeekDay="+DAYS[key.getIntValue()]+", sumValue="+val.getDoubleValue());
    }
   
View Full Code Here

    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
   
    System.out.println("getValueSumByCountry");
    System.out.println("times");
    for(int i=0;i<10;++i){
      long st = System.nanoTime();
      result = or.valueSumByCountry();
      System.out.print(((System.nanoTime()-st)/1000000.0)+";");
    }
   
    System.out.println("\n");
    for(ViewResult.Row r : result.getRows()){
      JsonNode key = r.getKeyAsNode();
      JsonNode val = r.getValueAsNode();
//      System.out.println("Country="+key.get(0)+", year="+key.get(1)+", sumValue="+val.getDoubleValue());
    }
   
View Full Code Here

    Map<String,Integer> supps = new HashMap<>();
    System.out.println("getQuantityBySupplier");
    System.out.println("times");
   
    ViewResult result = null;
    for(int i=0;i<10;++i){
      long st = System.nanoTime();
     
      result = or.productsWithQuantity();
     
      for (ViewResult.Row row : result.getRows()) {
       
        for(Product p : allProd) {
          if(row.getKey().equals(p.getProductID())) {
            if(supps.containsKey(p.getSupplierID())) {
              int quantity = supps.get(p.getSupplierID());
              quantity += Integer.parseInt(row.getValue());
              supps.put(p.getSupplierID(), quantity);
              break;
            } else {
              supps.put(p.getSupplierID(), Integer.parseInt(row.getValue()));
            }
          }
        }
      }
      System.out.print(((System.nanoTime()-st)/1000000.0)+";");
    }
   
    System.out.println(allProd.size());
    System.out.println(result.getSize());
    for(String supp : supps.keySet()) {
      System.out.println("SupplierId: "+supp+" , quantity: "+supps.get(supp));
    }
  }
View Full Code Here

   
    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
    OrderRepository or = new OrderRepository(db)
    ViewResult result = null;
   
   
    System.out.println("getAvgTimePerYear");
    System.out.println("times");
    /*for(int i=0;i<10;++i){
      long st = System.nanoTime();
      result = or.getAvgTimePerYear();
      System.out.print(((System.nanoTime()-st)/1000000.0)+";");
    }*/
    result = iterate(result,or);
   
    System.out.println("\n");
    for(ViewResult.Row row : result.getRows()) {
      System.out.println("Year: "+row.getKey()+", Average time: "+row.getValueAsNode().get(0)+" days");
    }
   
   
   
View Full Code Here

    super(Shipper.class,db);
    initStandardDesignDocument();
  }
 
  public int getIdSum() {
    ViewResult r = db.queryView(createQuery("id_sum"));
        return r.getRows().get(0).getValueAsInt();
  }
View Full Code Here

        HashMap map = new HashMap();
        // 1.0 and earlier will fail
        try {
            CouchDbConnector replicator = instance.createConnector("_replicator", false);
            ViewQuery query = new ViewQuery().allDocs().includeDocs(true);
            ViewResult result = replicator.queryView(query);
            for (Row row : result) {
                String replicationID = row.getDocAsNode().get("_replication_id").getTextValue();
                map.put(replicationID.substring(0,4), replicationID);
            }
        } catch (Exception e) {}
View Full Code Here

        ObjectMapper mapper = new ObjectMapper();

        ViewQuery query = new ViewQuery();
        query.allDocs().startKey("_design").endKey("_design0").includeDocs(true);
        ViewResult result = src.queryView(query);

        int totalAttachments = countAttachments(result);

        System.out.println("Total Attachments: " + totalAttachments);
View Full Code Here

    }

    @Override
    public byte[] getPrivateKeySalt() {
        final ViewQuery viewQuery = new ViewQuery().dbPath(db.path()).viewName(Views.SERVER.viewName()).designDocId(designDocument.getId());
        final ViewResult viewResult = db.queryView(viewQuery);
        if (viewResult.isEmpty()) {
            return new byte[]{};
        }
        final Row row = viewResult.getRows().get(0);
        return row.getKeyAsNode().get("salt").asText().getBytes(UTF_8);
    }
View Full Code Here

TOP

Related Classes of org.ektorp.ViewResult

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.