zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #16935
[Merge] lp:~zorba-coders/zorba/cast-to-simple-type into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/cast-to-simple-type into lp:zorba.
Commit message:
fixed performance regression due to unconditional schema creation
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/cast-to-simple-type/+merge/142685
fixed performance regression due to unconditional schema creation
--
https://code.launchpad.net/~zorba-coders/zorba/cast-to-simple-type/+merge/142685
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/core/sequencetypes.cpp'
--- src/runtime/core/sequencetypes.cpp 2012-12-29 06:48:09 +0000
+++ src/runtime/core/sequencetypes.cpp 2013-01-10 13:18:51 +0000
@@ -230,7 +230,7 @@
const UserDefinedXQType* udt;
store::SchemaTypeCode targetType;
- const TypeManager* tm = theSctx->get_typemanager();
+ TypeManager* tm = theSctx->get_typemanager();
CastIteratorState* state;
DEFAULT_STACK_INIT(CastIteratorState, state, planState);
@@ -336,7 +336,7 @@
bool res;
store::Item_t item;
- const TypeManager* tm = theSctx->get_typemanager();
+ TypeManager* tm = theSctx->get_typemanager();
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
=== modified file 'src/runtime/numerics/format_integer_impl.cpp'
--- src/runtime/numerics/format_integer_impl.cpp 2012-09-19 21:16:15 +0000
+++ src/runtime/numerics/format_integer_impl.cpp 2013-01-10 13:18:51 +0000
@@ -762,7 +762,7 @@
utf8_string<zstring> utf8_picture(pictureString);
xs_integer valueInteger;
bool is_neg = false;
- const TypeManager* tm = theSctx->get_typemanager();
+ TypeManager* tm = theSctx->get_typemanager();
const RootTypeManager& rtm = GENV_TYPESYSTEM;
PlanIteratorState* state;
@@ -788,10 +788,11 @@
{
consumeNext(language_item, theChildren[2].getp(), planState);
languageString = language_item->getStringValue();
+
if(!GenericCast::isCastable(languageString, &*rtm.LANGUAGE_TYPE_ONE, tm))
{
- throw XQUERY_EXCEPTION(err::FOFI0001, ERROR_PARAMS( languageString ), ERROR_LOC( loc )
- );
+ throw XQUERY_EXCEPTION(err::FOFI0001,
+ ERROR_PARAMS(languageString), ERROR_LOC(loc));
}
}
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp 2013-01-08 11:07:41 +0000
+++ src/types/casting.cpp 2013-01-10 13:18:51 +0000
@@ -2043,7 +2043,7 @@
const xqtref_t& targetType,
const namespace_context* nsCtx,
std::vector<store::Item_t>& resultList,
- const TypeManager* tm,
+ TypeManager* tm,
const QueryLoc& loc)
{
const TypeManager* ttm = targetType->get_manager();
@@ -2075,6 +2075,9 @@
{
ZORBA_ASSERT(targetType->type_kind() == XQType::USER_DEFINED_KIND);
+#ifndef ZORBA_NO_XMLSCHEMA
+ tm->initializeSchema();
+
Schema* schema = tm->getSchema();
const UserDefinedXQType* udt =
@@ -2129,6 +2132,7 @@
RAISE_ERROR(err::FORG0001, loc,
ERROR_PARAMS(item->getStringValue(), ZED(NoCastTo_34o), udt->toSchemaString()));
} // union
+#endif // ZORBA_NO_XMLSCHEMA
} // list or union
}
@@ -2692,7 +2696,7 @@
bool GenericCast::isCastable(
const store::Item_t& aItem,
const XQType* targetType,
- const TypeManager* tm)
+ TypeManager* tm)
{
#ifndef ZORBA_NO_XMLSCHEMA
if (targetType->type_kind() == XQType::USER_DEFINED_KIND )
@@ -2700,6 +2704,8 @@
const UserDefinedXQType* udt = static_cast<const UserDefinedXQType*>(targetType);
if (!udt->isComplex())
{
+ tm->initializeSchema();
+
return tm->getSchema()->
isCastableUserSimpleTypes(aItem->getStringValue(), targetType);
}
@@ -2746,7 +2752,7 @@
bool GenericCast::isCastable(
const zstring& str,
const XQType* aTargetType,
- const TypeManager* tm)
+ TypeManager* tm)
{
#ifndef ZORBA_NO_XMLSCHEMA
if (aTargetType->type_kind() == XQType::USER_DEFINED_KIND )
@@ -2754,6 +2760,8 @@
const UserDefinedXQType* udt = static_cast<const UserDefinedXQType*>(aTargetType);
if (!udt->isComplex())
{
+ tm->initializeSchema();
+
return tm->getSchema()->
isCastableUserSimpleTypes(str,
udt->getBaseType().getp());
=== modified file 'src/types/casting.h'
--- src/types/casting.h 2012-12-28 11:53:57 +0000
+++ src/types/casting.h 2013-01-10 13:18:51 +0000
@@ -89,7 +89,7 @@
const xqtref_t& targetType,
const namespace_context* nsCtx,
std::vector<store::Item_t>& resultList,
- const TypeManager* tm,
+ TypeManager* tm,
const QueryLoc& loc);
static bool castStringToAtomic(
@@ -138,12 +138,12 @@
static bool isCastable(
const store::Item_t& item,
const XQType* targetType,
- const TypeManager* tm);
+ TypeManager* tm);
static bool isCastable(
const zstring& stringValue,
const XQType* targetType,
- const TypeManager* tm);
+ TypeManager* tm);
};
} /* namespace zorba */
=== modified file 'src/types/typemanagerimpl.cpp'
--- src/types/typemanagerimpl.cpp 2013-01-08 11:07:41 +0000
+++ src/types/typemanagerimpl.cpp 2013-01-10 13:18:51 +0000
@@ -71,7 +71,8 @@
m_parent(parent),
m_schema(NULL)
{
- initializeSchema();
+ // This is too expensive. Do it only if relly necessary
+ //initializeSchema();
}
Follow ups