~zorba-coders/zorba/bug900677

« back to all changes in this revision

Viewing changes to src/compiler/rewriter/rules/index_join_rule.cpp

  • Committer: David Graf
  • Date: 2012-07-12 08:36:59 UTC
  • mfrom: (10618.1.311 zorba)
  • Revision ID: davidagraf@gmail.com-20120712083659-erczetl0ls2ganfq
merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
  // The domain of the outer var must contain more than 1 item.
281
281
  xqtref_t outerDomainType = predInfo.theOuterVar->get_domain_expr()->get_return_type();
282
282
 
283
 
  if (TypeOps::type_max_cnt(tm, *outerDomainType) < 2)
 
283
  if (outerDomainType->max_card() < 2)
284
284
    return false;
285
285
 
286
286
  // The expr that defines the inner var must not depend on the outer var.
298
298
  xqtref_t innerType = predInfo.theInnerOp->get_return_type();
299
299
  xqtref_t primeOuterType = TypeOps::prime_type(tm, *outerType);
300
300
  xqtref_t primeInnerType = TypeOps::prime_type(tm, *innerType);
301
 
  TypeConstants::quantifier_t outerQuant = TypeOps::quantifier(*outerType);
302
 
  TypeConstants::quantifier_t innerQuant = TypeOps::quantifier(*innerType);
 
301
  TypeConstants::quantifier_t outerQuant = outerType->get_quantifier();
 
302
  TypeConstants::quantifier_t innerQuant = innerType->get_quantifier();
303
303
  const QueryLoc& innerLoc = predInfo.theInnerOp->get_loc();
304
304
  const QueryLoc& outerLoc = predInfo.theOuterOp->get_loc();
305
305
 
518
518
                         innerPosInStack))
519
519
      return;
520
520
 
521
 
    ulong numClauses = innerFlwor->num_clauses();
 
521
    csize numClauses = innerFlwor->num_clauses();
522
522
 
523
523
    if (innerFlwor->defines_variable(predInfo.theOuterVar) >= 0 ||
524
524
        mostInnerVarPos < numClauses-1)
529
529
 
530
530
      flwor_expr_t nestedFlwor = new flwor_expr(sctx, nestedLoc, false);
531
531
 
532
 
      for (ulong i = mostInnerVarPos+1; i < numClauses; ++i)
 
532
      for (csize i = mostInnerVarPos+1; i < numClauses; ++i)
533
533
      {
534
534
        nestedFlwor->add_clause(innerFlwor->get_clause(i));
535
535
      }
536
536
 
537
 
      for (ulong i = numClauses - 1; i > mostInnerVarPos; --i)
 
537
      for (csize i = numClauses - 1; i > mostInnerVarPos; --i)
538
538
      {
539
539
        innerFlwor->remove_clause(i);
540
540
      }
563
563
      {
564
564
        block_expr* seqExpr = static_cast<block_expr*>(returnExpr);
565
565
 
566
 
        ulong numArgs = seqExpr->size();
567
 
        ulong arg;
 
566
        csize numArgs = seqExpr->size();
 
567
        csize arg;
568
568
        for (arg = 0; arg < numArgs; ++arg)
569
569
        {
570
570
          if ((*seqExpr)[arg]->get_function_kind() !=
590
590
  }
591
591
  else
592
592
  {
593
 
    // All the variables referenced by the inner domain expr are defined after
594
 
    // the outer var. In this case, Find the flwor expr defining the outer var
595
 
    // and create the index just before this flwor.
 
593
    // The inner domain expr does not reference any flwor vars. In this case,
 
594
    // find the flwor expr defining the outer var and create the index just 
 
595
    // before this flwor.
596
596
    flwor_expr* outerFlworExpr = NULL;
597
597
    ulong outerPosInStack = 0;
598
598
    ulong dummy = 0;