Package dovetaildb.iter

Examples of dovetaildb.iter.Iter


    buffer.put("ID2", Util.literalSMap().p("name", "Jill").p("gender", "f").p("age", 23));
    batch.put("people", buffer);
    long lcommit = db.commit(db.getHighestCompletedTxnId(), batch);
    db.rebuildPrimarySegment(1000);
    assertTrue(db.rebuildCatchupIter());
    Iter i = db.query("people", db.getHighestCompletedTxnId(), Util.literalMap(), Util.literalSMap());
    assertTrue(i.hasNext());
    String name1 = (String)((Map)i.next()).get("name");
    assertTrue(i.hasNext());
    String name2 = (String)((Map)i.next()).get("name");
    assertFalse(i.hasNext());
    assertEquals(Util.literalSet().a(name1).a(name2), Util.literalSet().a("Joe").a("Jill"));
  }
View Full Code Here


      } catch(Util.JsonParseRuntimeException e) {
        throw new ApiException("InvalidBookmark", "Invalid compare JSON value in bookmark: "+e.getMessage());
      }
    }
    Object scorePattern = options.get("score");
    Iter iter = subService.query(bag, txnId, query, options);
    if (scorePattern == null) {
      return new SlicedIter(iter, offset, limit);
    }
    ScoreComponent scorer = parseScorePattern(scorePattern, ArrayBytes.EMPTY_BYTES);
    while(iter.hasNext()) {
      Object resultObject = iter.next();
      double score;
      DbResult dbResult = null;
      if (resultObject instanceof DbResultMapView) {
        dbResult = ((DbResultMapView)resultObject).getDbResult();
        score = scorer.score(dbResult, minScore, maxScore);
      } else {
        score = scorer.scoreObject(resultObject, minScore, maxScore);
      }
      if (Double.isNaN(score)) continue;
      if (score < minScore) continue;
      if (score > maxScore) continue;
      if (score == maxScore) {
        if (dbResult.derefByKey(secondaryField).compareTo(secondaryValue) <= 0) continue;
      }
     
      // copy in an appropriate fashion
      if (dbResult != null && dbResult instanceof QueryNodeDbResult) {
        resultObject = new QueryNodeDbResultMarker((QueryNodeDbResult)dbResult);
//        resultObject = dbResult.deepCopy();
      } else {
        resultObject = Util.jsonDecode(Util.jsonEncode(resultObject));
      }
      hits.offer(new HitRec(score, resultObject));
     
      if (hits.size() > limit) {
        hits.remove();
        double newMinScore = hits.peek().score;
        if (newMinScore > minScore) {
          minScore = newMinScore;
          Iter newIter = scorer.narrowScoreRange(minScore, maxScore, iter);
          iter = newIter;
        }
      }
    }
    final int numHits = hits.size();
View Full Code Here

    data.getEntries().put(id, entry);
  }

  public Iter query(String bag, Object query, Map<String,Object> options) {
    ApiBuffer data = getDataForBag(bag);
    Iter i1 = data.query(query, options);
    List idList = new ArrayList();
    idList.add("|");
    idList.addAll(data.getDeletions());
    idList.addAll(data.getEntries().keySet());
    List notClause = Util.literalList().a("!").a(Util.literalMap().put("id", idList));
    query = Util.literalList().a("&").a(query).a(notClause);
    Iter i2 = this.db.query(bag, this.readTxnId, query, options);
    return new MergeIter(i1, i2);
  }
View Full Code Here

  public Iter query(String bag, Object query, Map<String,Object> options) {
    ApiBuffer data = getDataForBag(bag);
    if (data.isEmpty()) {
      return db.query(bag, readTxnId, query, options);
    } else {
      Iter i1 = data.query(query, options);
      List idList = new ArrayList();
      idList.add("|");
      idList.addAll(data.getDeletions());
      idList.addAll(data.getEntries().keySet());
      List notClause = Util.literalList().a("!").a(Util.literalMap().p("id", idList));
      query = Util.literalList().a("&").a(query).a(notClause);
      Iter i2 = db.query(bag, readTxnId, query, options);
      return new MergeIter(i1, i2);
    }
  }
View Full Code Here

        System.out.println("CHECKPOINT "+checkpoint);
        if (checkpoint == -2452059308835280636l) {
          System.out.println();
        }
       
        Iter iter = api.query("test", query, Util.literalSMap());
        List<Object> results = yank(iter);
       
        System.out.println("expctd "+JSONValue.toJSONString(matching));
        System.out.println("vs     "+results);
       
View Full Code Here

TOP

Related Classes of dovetaildb.iter.Iter

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.