Beispiel #1
0
  private void consumeChildEvaluation(LongTreeMap<Object> childResult) {
    boolean prepareResult = false;
    int size = childResult.size();
    if (size == 1 && expression.resultType == DataType.NUMBER) {
      Object resultItem = childResult.firstEntry().value;
      if (resultItem instanceof Double && ((Double) resultItem).isNaN()) {
        result.clear();
        prepareResult = true;
      }
    }

    if (size > 0) {
      if (predicateChain == 0) fireInstantResult(childResult);
      if (result.size() > 0) {
        if (nodeSetListener != null) {
          for (LongTreeMap.Entry<Object> entry = childResult.firstEntry();
              entry != null;
              entry = entry.next()) {
            if (result.put(entry.getKey(), entry.value) != null)
              nodeSetListener.discard(entry.getKey());
          }
        } else result.putAll(childResult);
      } else result = childResult;
    }
    consumedResult();

    if (prepareResult) resultPrepared();
  }
Beispiel #2
0
 private void consumedResult() {
   int resultSize = result.size();
   if (resultSize > 0 && !expression.many) {
     if (resultSize > 1) result.deleteEntry(result.lastEntry());
     if (expression.first) {
       if (pendingEvaluationHead == null
           || result.firstEntry().getKey() <= pendingEvaluationHead.order) resultPrepared();
       else if (!expired) {
         manuallyExpired = true;
         expired = true;
       }
     } else resultPrepared();
   } else if (expired && pendingEvaluationHead == null) resultPrepared();
 }
Beispiel #3
0
 @SuppressWarnings({"unchecked"})
 public Object computeResult() {
   if (expression.forEach) {
     List<Object> result = new ArrayList<Object>(evaluations.size());
     for (LongTreeMap.Entry entry = evaluations.firstEntry(); entry != null; entry = entry.next())
       result.add(computeResultItem(((EvaluationInfo) entry.value).result));
     return result;
   } else {
     LongTreeMap result = new LongTreeMap();
     for (LongTreeMap.Entry<EvaluationInfo> entry = evaluations.firstEntry();
         entry != null;
         entry = entry.next()) result.putAll(entry.value.result);
     return computeResultItem(result);
   }
 }
Beispiel #4
0
 @SuppressWarnings({"unchecked", "UnnecessaryBoxing"})
 private Object computeResultItem(LongTreeMap result) {
   switch (expression.resultType) {
     case NODESET:
     case STRINGS:
     case NUMBERS:
       return new ArrayList(result.values());
     case NUMBER:
       if (expression.relativeExpression instanceof Count) return new Double(result.size());
       else {
         double d = 0;
         for (LongTreeMap.Entry entry = result.firstEntry(); entry != null; entry = entry.next())
           d += (Double) entry.value;
         return d;
       }
     case BOOLEAN:
       return !result.isEmpty();
     default:
       if (result.isEmpty()) return expression.resultType.defaultValue;
       else return result.firstEntry().value;
   }
 }