uint32_t deHashChildren( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it, XQPCollator* collator, int timezone) { uint32_t lHash = FNV_32_INIT; uint32_t lInnerHash; store::Item_t child; it->open(); while (it->next(child)) { if (child->getNodeKind() == store::StoreConsts::piNode || child->getNodeKind() == store::StoreConsts::commentNode) continue; lInnerHash = deHash(loc, sctx, child, collator, timezone); lHash = hashfun::h32(&lInnerHash, sizeof(lInnerHash), lHash); } return lHash; }
uint32_t deHashAttributes( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it, XQPCollator* collator, int timezone) { uint32_t lHash = FNV_32_INIT; std::vector<uint32_t> lInnerHashes; store::Item_t attr; it->open(); while (it->next(attr)) { lInnerHashes.push_back(deHash(loc, sctx, attr, collator, timezone)); } std::sort(lInnerHashes.begin(), lInnerHashes.end()); for(std::vector<uint32_t>::iterator it = lInnerHashes.begin(); it != lInnerHashes.end(); ++it) { lHash = hashfun::h32(&(*it), sizeof(*it), lHash); } return lHash; }
bool deepEqualAttributes( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it1, const store::Iterator_t& it2, XQPCollator* collator, int timezone, bool raiseError) { store::Item_t child1, child2; int c1count = 0, c2count = 0; it1->open(); it2->open(); while (it1->next(child1)) { c1count++; it2->reset(); bool found = false; while (it2->next(child2)) { if (deepEqual(loc, sctx, child1, child2, collator, timezone, raiseError)) { found = true; break; } } if (!found) return false; } it2->reset(); while (it2->next(child2)) c2count++; if (c1count != c2count) return false; return true; }
bool deepEqualChildren( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it1, const store::Iterator_t& it2, XQPCollator* collator, int timezone, bool raiseError) { store::Item_t child1, child2; bool c1Valid, c2Valid; it1->open(); it2->open(); while (1) { while ((c1Valid = it1->next(child1)) && (child1->getNodeKind() == store::StoreConsts::piNode || child1->getNodeKind() == store::StoreConsts::commentNode)) ; while ((c2Valid = it2->next(child2)) && (child2->getNodeKind() == store::StoreConsts::piNode || child2->getNodeKind() == store::StoreConsts::commentNode)) ; if (!c1Valid && !c2Valid) return true; else if (!c1Valid || !c2Valid) return false; else if (!deepEqual(loc, sctx, child1, child2, collator, timezone, raiseError)) return false; } return true; }
void dynamic_context::set_variable( ulong varid, const store::Item_t& varname, const QueryLoc& loc, store::Iterator_t& valueIter) { if (varid >= theVarValues.size() || theVarValues[varid].theState == VarValue::undeclared) { RAISE_ERROR(err::XPDY0002, loc, ERROR_PARAMS(ZED(XPDY0002_VariableUndeclared_2), varname->getStringValue())); } valueIter->open(); // For now, use eager eval because the assignment expression may reference // the variable itself, and the current value of the variable is overwriten // here by this temp sequence. TODO: use lazy eval if we know the the // assignment expression does not reference the variable itself. store::TempSeq_t seq = GENV_STORE.createTempSeq(valueIter, false); // no lazy eval valueIter->close(); VarValue& var = theVarValues[varid]; // variables can be set multiple times, so we need to make sure to remove // previously set temp sequences if (var.theState == VarValue::item) { assert(var.theValue.item != NULL); var.theValue.item->removeReference(); } else if (var.theState == VarValue::temp_seq) { assert(var.theValue.temp_seq != NULL); RCHelper::removeReference(var.theValue.temp_seq); } else if (var.theState == VarValue::declared) { assert(var.theValue.item == NULL); } else { ZORBA_ASSERT(false); } var.theState = VarValue::temp_seq; var.theValue.temp_seq = seq.release(); }