Ejemplo n.º 1
0
 private boolean constraintCanBeAddedToExisting(List4 candidatesList, QCon constraint) {
   Iterator4 j = new Iterator4Impl(candidatesList);
   while (j.moveNext()) {
     QCandidates candidates = (QCandidates) j.current();
     if (candidates.fitsIntoExistingConstraintHierarchy(constraint)) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
 private void addConstraintToCandidatesList(List4 candidatesList, QCon qcon) {
   if (candidatesList == null) {
     return;
   }
   Iterator4 j = new Iterator4Impl(candidatesList);
   while (j.moveNext()) {
     QCandidates candidates = (QCandidates) j.current();
     candidates.addConstraint(qcon);
   }
 }
Ejemplo n.º 3
0
  public Iterator4 executeSnapshot() {
    final CreateCandidateCollectionResult r = createCandidateCollection();

    final Collection4 executionPath = executionPath(r);

    Iterator4 candidatesIterator = new Iterator4Impl(r.candidateCollection);

    Collection4 snapshots = new Collection4();
    while (candidatesIterator.moveNext()) {
      QCandidates candidates = (QCandidates) candidatesIterator.current();
      snapshots.add(candidates.executeSnapshot(executionPath));
    }

    Iterator4 snapshotsIterator = snapshots.iterator();
    final CompositeIterator4 resultingIDs = new CompositeIterator4(snapshotsIterator);

    if (!r.checkDuplicates) {
      return resultingIDs;
    }

    return checkDuplicates(resultingIDs);
  }
Ejemplo n.º 4
0
  public void executeLocal(final IdListQueryResult result) {
    checkConstraintsEvaluationMode();

    CreateCandidateCollectionResult r = createCandidateCollection();

    boolean checkDuplicates = r.checkDuplicates;
    boolean topLevel = r.topLevel;
    List4 candidateCollection = r.candidateCollection;

    if (Debug4.queries) {
      logConstraints();
    }

    if (candidateCollection != null) {

      final Collection4 executionPath = topLevel ? null : fieldPathFromTop();

      Iterator4 i = new Iterator4Impl(candidateCollection);
      while (i.moveNext()) {
        ((QCandidates) i.current()).execute();
      }

      if (candidateCollection._next != null) {
        checkDuplicates = true;
      }

      if (checkDuplicates) {
        result.checkDuplicates();
      }

      final ObjectContainerBase stream = stream();
      i = new Iterator4Impl(candidateCollection);
      while (i.moveNext()) {
        QCandidates candidates = (QCandidates) i.current();
        if (topLevel) {
          candidates.traverse(result);
        } else {
          candidates.traverse(
              new Visitor4() {
                public void visit(Object a_object) {
                  QCandidate candidate = (QCandidate) a_object;
                  if (candidate.include()) {
                    TreeInt ids = new TreeInt(candidate._key);
                    final ByRef<TreeInt> idsNew = new ByRef<TreeInt>();
                    Iterator4 itPath = executionPath.iterator();
                    while (itPath.moveNext()) {
                      idsNew.value = null;
                      final String fieldName = (String) (itPath.current());
                      if (ids != null) {
                        ids.traverse(
                            new Visitor4() {
                              public void visit(Object treeInt) {
                                int id = ((TreeInt) treeInt)._key;
                                StatefulBuffer reader = stream.readStatefulBufferById(_trans, id);
                                if (reader != null) {
                                  ObjectHeader oh = new ObjectHeader(stream, reader);
                                  CollectIdContext context =
                                      new CollectIdContext(_trans, oh, reader);
                                  oh.classMetadata().collectIDs(context, fieldName);
                                  Tree.traverse(
                                      context.ids(),
                                      new Visitor4<TreeInt>() {
                                        public void visit(TreeInt node) {
                                          idsNew.value = TreeInt.add(idsNew.value, node._key);
                                        }
                                      });
                                }
                              }
                            });
                      }
                      ids = (TreeInt) idsNew.value;
                    }
                    if (ids != null) {
                      ids.traverse(
                          new Visitor4() {
                            public void visit(Object treeInt) {
                              result.addKeyCheckDuplicates(((TreeInt) treeInt)._key);
                            }
                          });
                    }
                  }
                }
              });
        }
      }
    }
    sort(result);
  }