Examples of Iter


Examples of cambridge.runtime.Iter

            iter.next();
        }
    }

    private void iterateDouble(ExpressionContext context, TagNode tag, Writer out, double[] o) throws IOException, TemplateEvaluationException {
        Iter iter = new Iter();
        context.put(getIterObjectName(), iter);
        for (int i=0; i<o.length; i++) {
          if (i == o.length-1)
            iter.setLast();

            context.put(getCurrentObjectName(), o[i]);
            tag.execute(context, out);
            iter.next();
        }
    }
View Full Code Here

Examples of cambridge.runtime.Iter

            iter.next();
        }
    }

    private void iterateByte(ExpressionContext context, TagNode tag, Writer out, byte[] o) throws IOException, TemplateEvaluationException {
        Iter iter = new Iter();
        context.put(getIterObjectName(), iter);
        for (int i=0; i<o.length; i++) {
          if (i == o.length-1)
            iter.setLast();

            context.put(getCurrentObjectName(), o[i]);
            tag.execute(context, out);
            iter.next();
        }
    }
View Full Code Here

Examples of cambridge.runtime.Iter

            iter.next();
        }
    }

    private void iterateChar(ExpressionContext context, TagNode tag, Writer out, char[] o) throws IOException, TemplateEvaluationException {
        Iter iter = new Iter();
        context.put(getIterObjectName(), iter);
        for (int i=0; i<o.length; i++) {
          if (i == o.length-1)
            iter.setLast();

            context.put(getCurrentObjectName(), o[i]);
            tag.execute(context, out);
            iter.next();
        }
    }
View Full Code Here

Examples of cambridge.runtime.Iter

            iter.next();
        }
    }

    private void iterateBoolean(ExpressionContext context, TagNode tag, Writer out, boolean[] o) throws IOException, TemplateEvaluationException {
        Iter iter = new Iter();
        context.put(getIterObjectName(), iter);
        for (int i=0; i<o.length; i++) {
          if (i == o.length-1)
            iter.setLast();

            context.put(getCurrentObjectName(), o[i]);
            tag.execute(context, out);
            iter.next();
        }
    }
View Full Code Here

Examples of cambridge.runtime.Iter

    }

    @Override
    public void doExecute(ExpressionContext context, TagNode tag, Writer out) throws TemplateEvaluationException, IOException {
        try {
            Iter iter = new Iter();
            while (expression.asBoolean(context)) {
                context.put(Expressions.ITER_OBJECT, iter);
                tag.execute(context, out);
                iter.next();
            }
        } catch (ExpressionEvaluationException e) {
            throw new TemplateEvaluationException(e, "Could not execute the expression: " +
                    e.getMessage() + ", on line: " + tag.getBeginLine() + ", column: " +
                    tag.getBeginColumn(), tag.getBeginLine(), tag.getBeginColumn(), tag.getTagName());
View Full Code Here

Examples of cambridge.runtime.Iter

    }

    @Override
    public void doExecute(ExpressionContext context, TagNode tag, Writer out) throws TemplateEvaluationException, IOException {
        try {
            Iter iter = new Iter();
            for (int i = from.asInt(context); i <= to.asInt(context); i++) {
              if (i == to.asInt(context))
                iter.setLast();

                context.put(Expressions.CURRENT_OBJECT, i);
                context.put(Expressions.ITER_OBJECT, iter);
                tag.execute(context, out);
                iter.next();
            }
        } catch (ExpressionEvaluationException e) {
            throw new TemplateEvaluationException(e, "Could not execute the expression: " + e.getMessage() +
                    ", on line: " + tag.getBeginLine() + ", column: " + tag.getBeginColumn(),
                    tag.getBeginLine(), tag.getBeginColumn(), tag.getTagName());
View Full Code Here

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

Examples of dovetaildb.iter.Iter

      } 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

Examples of dovetaildb.iter.Iter

    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

Examples of dovetaildb.iter.Iter

  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
TOP
Copyright © 2018 www.massapi.com. 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.