Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Requested reviews: Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/90336 type-related optimizagtions of boolean iterators -- https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/90336 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog' --- ChangeLog 2012-01-25 21:20:30 +0000 +++ ChangeLog 2012-01-26 21:45:33 +0000 @@ -10,7 +10,8 @@ * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) * Fixed bug 909126 (bug in cloning of var_expr) * Fixed bug in destruction of exit_catcher_expr - * Types-related optimization for the comparison operators + * Types-related optimizations for runtime operators (comparisons, FnBoolean, Or, And, + Compare). * Fixed bug #911585 (management of variables during eval) * Fixed bug #866423 (fn:empty and fn:exists iterators must reset their input in case of early-out) === modified file 'src/api/item.cpp' --- src/api/item.cpp 2012-01-18 18:09:34 +0000 +++ src/api/item.cpp 2012-01-26 21:45:33 +0000 @@ -32,6 +32,7 @@ #include "api/unmarshaller.h" #include "store/api/item.h" +#include "store/api/item_factory.h" #include "store/api/store.h" #include "store/api/iterator.h" #include "store/api/collection.h" @@ -264,7 +265,12 @@ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);) - return &*m_item->getEBV(); + bool value = m_item->getEBV(); + + store::Item_t result; + GENV_ITEMFACTORY->createBoolean(result, value); + + return result.getp(); ITEM_CATCH return Item(); === modified file 'src/compiler/rewriter/rules/fold_rules.cpp' --- src/compiler/rewriter/rules/fold_rules.cpp 2011-11-22 13:28:23 +0000 +++ src/compiler/rewriter/rules/fold_rules.cpp 2012-01-26 21:45:33 +0000 @@ -840,7 +840,7 @@ if ((constArg = dynamic_cast<const const_expr*>(arg)) != NULL) { - if (constArg->get_val()->getEBV()->getBooleanValue() == shortcircuit_val) + if (constArg->get_val()->getEBV() == shortcircuit_val) return new const_expr(fo->get_sctx(), LOC(fo), (xs_boolean)shortcircuit_val); } else === modified file 'src/functions/func_booleans_impl.cpp' --- src/functions/func_booleans_impl.cpp 2012-01-23 10:06:24 +0000 +++ src/functions/func_booleans_impl.cpp 2012-01-26 21:45:33 +0000 @@ -874,7 +874,6 @@ GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_STAR, GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_STAR, GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE)); -// end Atomic Values Equivalent } === modified file 'src/runtime/booleans/BooleanImpl.cpp' --- src/runtime/booleans/BooleanImpl.cpp 2012-01-24 11:24:56 +0000 +++ src/runtime/booleans/BooleanImpl.cpp 2012-01-26 21:45:33 +0000 @@ -89,7 +89,7 @@ const PlanIterator* iter, bool negate) { - store::Item_t item, temp; + store::Item_t item; bool result; bool is_sequence; @@ -107,38 +107,41 @@ } else { - xqtref_t type = tm->create_value_type(item); - is_sequence = consumeNext(temp, iter, planState); + store::SchemaTypeCode type = item->getTypeCode(); + + store::Item_t item2; + is_sequence = consumeNext(item2, iter, planState); + if (!is_sequence && - (TypeOps::is_equal(tm, *type, *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE) - || TypeOps::is_subtype(tm, *type, *GENV_TYPESYSTEM.STRING_TYPE_ONE) - || TypeOps::is_subtype(tm, *type, *GENV_TYPESYSTEM.ANY_URI_TYPE_ONE) - || TypeOps::is_subtype(tm, *type, *GENV_TYPESYSTEM.UNTYPED_ATOMIC_TYPE_ONE) - || TypeOps::is_numeric(tm, *type))) + (type == store::XS_BOOLEAN || + TypeOps::is_subtype(type, store::XS_STRING) || + TypeOps::is_subtype(type, store::XS_ANY_URI) || + type == store::XS_UNTYPED_ATOMIC || + TypeOps::is_numeric(type))) { // atomic type xs_boolean, xs_string, xs_anyURI, xs_untypedAtomic // => effective boolean value is defined in the items - temp = item->getEBV(); - result = negate ? (negate ^ temp->getBooleanValue()) : temp->getBooleanValue(); + bool temp = item->getEBV(); + result = negate ? (negate ^ temp) : temp; } else { if (is_sequence) - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( BadArgTypeForFn_2o34o ), "", "fn:boolean", - ZED( EBVNotDefSeq_5 ), *type - ), - ERROR_LOC( loc ) - ); + { + xqtref_t type = tm->create_value_type(item); + + RAISE_ERROR(err::FORG0006, loc, + ERROR_PARAMS(ZED(BadArgTypeForFn_2o34o), + "", "fn:boolean", + ZED(EBVNotDefSeq_5), + *type)); + } else - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( ZED( BadArgTypeForFn_2o34o ), "", "fn:boolean" ), - ERROR_LOC( loc ) - ); + { + RAISE_ERROR(err::FORG0006, loc, + ERROR_PARAMS(ZED(BadArgTypeForFn_2o34o), "", "fn:boolean" )); + } } } === modified file 'src/store/api/item.h' --- src/store/api/item.h 2012-01-11 17:30:25 +0000 +++ src/store/api/item.h 2012-01-26 21:45:33 +0000 @@ -195,7 +195,7 @@ * * @return result of Effective Boolean Value */ - virtual Item_t + virtual bool getEBV() const; /** === modified file 'src/store/naive/atomic_items.cpp' --- src/store/naive/atomic_items.cpp 2012-01-11 16:30:06 +0000 +++ src/store/naive/atomic_items.cpp 2012-01-26 21:45:33 +0000 @@ -63,16 +63,6 @@ /******************************************************************************* ********************************************************************************/ -store::Item_t AtomicItem::getAtomizationValue() const -{ - store::Item* lItem = const_cast<AtomicItem *>(this); - return lItem; -} - - -/******************************************************************************* - -********************************************************************************/ void AtomicItem::getTypedValue(store::Item_t& val, store::Iterator_t& iter) const { store::Item* lItem = const_cast<AtomicItem *>(this); @@ -589,12 +579,9 @@ } -store::Item_t UntypedAtomicItem::getEBV() const +bool UntypedAtomicItem::getEBV() const { - bool b = ! ( theValue == "" ); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return ! ( theValue == "" ); } @@ -645,7 +632,7 @@ } -store::Item_t QNameItem::getEBV() const +bool QNameItem::getEBV() const { throw XQUERY_EXCEPTION(err::FORG0006, ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "QName")); @@ -827,12 +814,9 @@ } -store::Item_t AnyUriItem::getEBV() const +bool AnyUriItem::getEBV() const { - bool b = ! (theValue == ""); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return ! (theValue == ""); } @@ -1600,12 +1584,9 @@ } -store::Item_t StringItem::getEBV() const +bool StringItem::getEBV() const { - bool b = ! ( theValue == "" ); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return ! ( theValue == "" ); } @@ -1675,7 +1656,7 @@ } -store::Item_t StreamableStringItem::getEBV() const +bool StreamableStringItem::getEBV() const { if (!theIsMaterialized) { @@ -2062,77 +2043,43 @@ } -store::Item_t DateTimeItem::getEBV() const +bool DateTimeItem::getEBV() const { switch (theValue.getFacet()) { case DateTime::DATE_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "xs:Date" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:Date")); case DateTime::TIME_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "xs:Time" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:Time")); case DateTime::GYEARMONTH_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), - "xs:GYearMonth" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:GYearMonth")); case DateTime::GYEAR_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "xs:GYear" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:GYear")); case DateTime::GMONTH_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "xs:GMonth" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:GMonth")); case DateTime::GMONTHDAY_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), - "xs:GMonthDay" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:GMonthDay")); case DateTime::GDAY_FACET: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "xs:GDay" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "xs:GDay")); default: - throw XQUERY_EXCEPTION( - err::FORG0006, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "dateTime" - ) - ); + throw XQUERY_EXCEPTION(err::FORG0006, + ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "dateTime")); } - return NULL; + return false; } @@ -2204,7 +2151,7 @@ } -store::Item_t DurationItem::getEBV() const +bool DurationItem::getEBV() const { RAISE_ERROR_NO_LOC(err::FORG0006, ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "duration")); @@ -2227,20 +2174,16 @@ } -store::Item_t DoubleItem::getEBV() const +bool DoubleItem::getEBV() const { - bool b; if (theValue.isNaN()) { - b = false; + return false; } else { - b = !theValue.isZero(); + return !theValue.isZero(); } - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; } @@ -2299,20 +2242,16 @@ } -store::Item_t FloatItem::getEBV() const +bool FloatItem::getEBV() const { - bool b; if (theValue.isNaN()) { - b = false; + return false; } else { - b = !theValue.isZero(); + return !theValue.isZero(); } - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; } @@ -2371,14 +2310,12 @@ } -store::Item_t DecimalItem::getEBV() const +bool DecimalItem::getEBV() const { - bool b = ( theValue != xs_decimal::zero() ); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return ( theValue != xs_decimal::zero() ); } + zstring DecimalItem::getStringValue() const { return theValue.toString(); @@ -2466,12 +2403,9 @@ } -store::Item_t IntegerItem::getEBV() const +bool IntegerItem::getEBV() const { - bool b = ( theValue != xs_integer::zero() ); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return ( theValue != xs_integer::zero() ); } @@ -2598,12 +2532,9 @@ } -store::Item_t LongItem::getEBV() const +bool LongItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -2659,14 +2590,12 @@ } -store::Item_t IntItem::getEBV() const +bool IntItem::getEBV() const { - bool b = ( theValue != (int32_t)0 ); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return ( theValue != (int32_t)0 ); } + zstring IntItem::getStringValue() const { zstring result; @@ -2719,12 +2648,9 @@ } -store::Item_t ShortItem::getEBV() const +bool ShortItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -2780,12 +2706,9 @@ } -store::Item_t ByteItem::getEBV() const +bool ByteItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -2847,12 +2770,9 @@ } -store::Item_t UnsignedLongItem::getEBV() const +bool UnsignedLongItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -2914,12 +2834,9 @@ } -store::Item_t UnsignedIntItem::getEBV() const +bool UnsignedIntItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -2981,12 +2898,9 @@ } -store::Item_t UnsignedShortItem::getEBV() const +bool UnsignedShortItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -3048,12 +2962,9 @@ } -store::Item_t UnsignedByteItem::getEBV() const +bool UnsignedByteItem::getEBV() const { - bool b = (theValue != 0); - store::Item_t bVal; - CREATE_BOOLITEM(bVal, b); - return bVal; + return (theValue != 0); } @@ -3103,9 +3014,9 @@ } -store::Item_t BooleanItem::getEBV() const +bool BooleanItem::getEBV() const { - return this->getAtomizationValue(); + return theValue; } === modified file 'src/store/naive/atomic_items.h' --- src/store/naive/atomic_items.h 2012-01-11 16:30:06 +0000 +++ src/store/naive/atomic_items.h 2012-01-26 21:45:33 +0000 @@ -78,8 +78,6 @@ SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; }) - store::Item_t getAtomizationValue() const; - void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const; bool castToLong(store::Item_t& result) const; @@ -145,7 +143,7 @@ return theBaseItem->compare(other->getBaseItem(), timezone, collation); } - store::Item_t getEBV() const { return theBaseItem->getEBV(); } + bool getEBV() const { return theBaseItem->getEBV(); } zstring getStringValue() const { return theBaseItem->getStringValue(); } @@ -317,7 +315,7 @@ long timezone = 0, const XQPCollator* collation = 0) const; - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const { return theValue; } @@ -372,7 +370,7 @@ store::Item* getType() const; - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -525,7 +523,7 @@ return theValue.compare(other->getString()); } - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const { return theValue; } @@ -746,7 +744,7 @@ long timezone = 0, const XQPCollator* aCollation = 0) const; - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const { return theValue; } @@ -795,7 +793,7 @@ long timezone = 0, const XQPCollator* collator = 0) const; - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -1061,7 +1059,7 @@ long timezone = 0, const XQPCollator* aCollation = 0) const; - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -1121,7 +1119,7 @@ return theValue.compare(other->getDurationValue()); } - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -1180,7 +1178,7 @@ return theValue.compare(other->getDoubleValue()); } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -1241,7 +1239,7 @@ return getDoubleValue().compare(other->getDoubleValue()); } - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -1318,7 +1316,7 @@ return theValue.compare(other->getDecimalValue()); } - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -1371,7 +1369,7 @@ long timezone = 0, const XQPCollator* aCollation = 0) const; - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -1539,7 +1537,7 @@ } } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -1621,7 +1619,7 @@ } } - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -1701,7 +1699,7 @@ } } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -1785,7 +1783,7 @@ } } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -1867,7 +1865,7 @@ } } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -1958,7 +1956,7 @@ } } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -2051,7 +2049,7 @@ } } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; @@ -2146,7 +2144,7 @@ } } - store::Item_t getEBV() const; + bool getEBV() const; zstring getStringValue() const; @@ -2200,7 +2198,7 @@ (theValue == false ? -1 : 1)); } - store::Item_t getEBV( ) const; + bool getEBV( ) const; zstring getStringValue() const; === modified file 'src/store/naive/item.cpp' --- src/store/naive/item.cpp 2012-01-10 10:52:15 +0000 +++ src/store/naive/item.cpp 2012-01-26 21:45:33 +0000 @@ -269,15 +269,12 @@ } -Item_t Item::getEBV() const +bool Item::getEBV() const { - throw ZORBA_EXCEPTION( - zerr::ZSTR0040_TYPE_ERROR, - ERROR_PARAMS( - ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), - getType()->getStringValue() - ) - ); + throw ZORBA_EXCEPTION(zerr::ZSTR0040_TYPE_ERROR, + ERROR_PARAMS(ZED(OperationNotDef_23), + ZED(EffectiveBooleanValue), + getType()->getStringValue())); } === modified file 'src/store/naive/node_items.cpp' --- src/store/naive/node_items.cpp 2012-01-11 17:30:25 +0000 +++ src/store/naive/node_items.cpp 2012-01-26 21:45:33 +0000 @@ -485,12 +485,10 @@ /******************************************************************************* ********************************************************************************/ -store::Item_t XmlNode::getEBV() const +bool XmlNode::getEBV() const { assert(!isConnectorNode()); - store::Item_t bVal; - GET_FACTORY().createBoolean(bVal, true); - return bVal; + return true; } === modified file 'src/store/naive/node_items.h' --- src/store/naive/node_items.h 2012-01-11 17:30:25 +0000 +++ src/store/naive/node_items.h 2012-01-26 21:45:33 +0000 @@ -469,7 +469,7 @@ getBaseURIInternal(uri, local); } - store::Item_t getEBV() const; + bool getEBV() const; store::Item* copy(store::Item* parent, const store::CopyMode& copymode) const; === modified file 'src/types/casting.cpp' --- src/types/casting.cpp 2012-01-24 11:24:56 +0000 +++ src/types/casting.cpp 2012-01-26 21:45:33 +0000 @@ -755,7 +755,7 @@ T1_TO_T2(flt, bool) { - result = aItem->getEBV(); + aFactory->createBoolean(result, aItem->getEBV()); return true; } @@ -811,7 +811,7 @@ T1_TO_T2(dbl, bool) { - result = aItem->getEBV(); + aFactory->createBoolean(result, aItem->getEBV()); return true; } @@ -850,7 +850,7 @@ T1_TO_T2(dec, bool) { - result = aItem->getEBV(); + aFactory->createBoolean(result, aItem->getEBV()); return true; } @@ -890,7 +890,7 @@ T1_TO_T2(int, bool) { - result = aItem->getEBV(); + aFactory->createBoolean(result, aItem->getEBV()); return true; } === modified file 'src/types/typemanagerimpl.cpp' --- src/types/typemanagerimpl.cpp 2012-01-10 10:52:15 +0000 +++ src/types/typemanagerimpl.cpp 2012-01-26 21:45:33 +0000 @@ -212,7 +212,7 @@ // Try to resolve the type name as a builtin atomic type RootTypeManager::qnametype_map_t& myMap = GENV_TYPESYSTEM.m_atomic_qnametype_map; - store::SchemaTypeCode code; + store::SchemaTypeCode code = store::XS_LAST; if (myMap.get(qname, code)) return create_builtin_atomic_type(code, quantifier); @@ -225,11 +225,8 @@ { throw XQUERY_EXCEPTION_VAR( error, - ERROR_PARAMS( - qname->getStringValue(), ZED( NotAmongInScopeSchemaTypes ) - ), - ERROR_LOC( loc ) - ); + ERROR_PARAMS(qname->getStringValue(), ZED(NotAmongInScopeSchemaTypes)), + ERROR_LOC(loc)); } else {
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp