← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1046559 into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/bug-1046559 into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1046559/+merge/124297

Fixed bug #1046559 (dynamic resolution between function invocation and jsoniq navigation).
Use char* instead of zstring as the hashmap key in json objects.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1046559/+merge/124297
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-09-13 08:28:50 +0000
+++ ChangeLog	2012-09-13 20:54:21 +0000
@@ -17,6 +17,7 @@
   * New memory management for compiler expressions (no more ref counting)
   * Exteneded some optimization rules (variable inlining/elimination and positional
     predicate rewrite) to general flwor expressions.
+  * Use char* instead of zstring as the hashmap key in json objects
 
 Bug Fixes/Other Changes:
   * Fixed bug #867227 (Improved error message for missing commas)
@@ -39,6 +40,8 @@
   * Fixed bug #866984 (better error message for an eval error)
   * Fixed bug #1047538 (jsoniq: SourceFinder::findLocalNodeSources missing
     json expressions)
+  * Fixed bug #1046559 (dynamic resolution between function invocation and jsoniq
+    navigation)
   * Fixed bug #932884 (HTML and XHTML serialization of empty elements)
   * Fixed bug #1045902 (file:last-modified returns current date time)
   * Fixed bug #1043976 (compiler warning in serialiser code)

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-09-11 22:55:05 +0000
+++ src/compiler/translator/translator.cpp	2012-09-13 20:54:21 +0000
@@ -10931,7 +10931,7 @@
   xqtref_t srcType = sourceExpr->get_return_type();
 
   if (!theSctx->is_feature_set(feature::hof) ||
-      (!TypeOps::is_subtype(tm, *srcType, *theRTM.ANY_FUNCTION_TYPE_STAR)))
+      (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ITEM_TYPE_STAR)))
   {
     if (numArgs != 1)
     {

=== modified file 'src/runtime/function_item/dynamic_fncall_iterator.cpp'
--- src/runtime/function_item/dynamic_fncall_iterator.cpp	2012-09-13 08:28:50 +0000
+++ src/runtime/function_item/dynamic_fncall_iterator.cpp	2012-09-13 20:54:21 +0000
@@ -143,7 +143,7 @@
 {
   store::Item_t item;
   store::Item_t targetItem;
-#if 0
+#ifdef ZORBA_WITH_JSON
   store::Item_t selectorItem1;
   store::Item_t selectorItem2;
   store::Item_t selectorItem3;
@@ -221,7 +221,7 @@
     state->thePlan->close(planState);
     state->theIsOpen = false;
   }
-#if 0 //def ZORBA_WITH_JSON
+#ifdef ZORBA_WITH_JSON
   else if (targetItem->isJSONObject() || targetItem->isJSONArray())
   {
     if (theChildren.size() != 2)

=== modified file 'src/store/naive/json_items.cpp'
--- src/store/naive/json_items.cpp	2012-09-11 22:55:05 +0000
+++ src/store/naive/json_items.cpp	2012-09-13 20:54:21 +0000
@@ -294,7 +294,7 @@
   ASSERT_INVARIANT();
   zstring lName = aName->getStringValue();
 
-  Keys::iterator ite = theKeys.find(lName);
+  Keys::iterator ite = theKeys.find(lName.c_str());
 
   if (ite == theKeys.end())
   {
@@ -308,7 +308,7 @@
     }
     
     csize lPosition = thePairs.size();
-    theKeys.insert(lName, lPosition);
+    theKeys.insert(lName.c_str(), lPosition);
     thePairs.push_back(std::make_pair(aName.getp(), lValue));
     aName->addReference();
     lValue->addReference();
@@ -363,7 +363,7 @@
   csize lPosition = 0;
   store::Item_t lValue;
 
-  if (!theKeys.get(lName, lPosition))
+  if (!theKeys.get(lName.c_str(), lPosition))
   {
     ASSERT_INVARIANT();
     return 0;
@@ -385,7 +385,7 @@
   lValue->removeReference();
 
   thePairs.erase(thePairs.begin() + lPosition);
-  theKeys.erase(lName);
+  theKeys.erase(lName.c_str());
 
   if (lPosition < thePairs.size())
   {
@@ -417,7 +417,7 @@
   zstring lName = aName->getStringValue();
   csize lPosition = 0;
 
-  if (!theKeys.get(lName, lPosition))
+  if (!theKeys.get(lName.c_str(), lPosition))
   {
     ASSERT_INVARIANT();
     return NULL;
@@ -464,13 +464,13 @@
   zstring lName = aName->getStringValue();
   zstring lNewName = aNewName->getStringValue();
 
-  if (theKeys.exists(lNewName))
+  if (theKeys.exists(lNewName.c_str()))
   {
     ASSERT_INVARIANT();
     return false;
   }
 
-  Keys::iterator ite = theKeys.find(lName);
+  Keys::iterator ite = theKeys.find(lName.c_str());
 
   if (ite == theKeys.end())
   {
@@ -485,7 +485,7 @@
   aNewName->addReference();
   thePairs[lPosition].first = aNewName.getp();
   theKeys.erase(ite);
-  theKeys.insert(lNewName, lPosition);
+  theKeys.insert(lNewName.c_str(), lPosition);
 
   ASSERT_INVARIANT();
   return true;
@@ -563,7 +563,7 @@
   zstring lName = aKey->getStringValue();
 
   csize lPosition = 0;
-  if (!theKeys.get(lName, lPosition))
+  if (!theKeys.get(lName.c_str(), lPosition))
   {
     return NULL;
   }

=== modified file 'src/store/naive/json_items.h'
--- src/store/naive/json_items.h	2012-09-11 22:55:05 +0000
+++ src/store/naive/json_items.h	2012-09-13 20:54:21 +0000
@@ -21,7 +21,7 @@
 #include <vector>
 
 #include <zorba/config.h>
-#include <zorbautils/hashmap_zstring.h>
+#include <zorbautils/hashmap_cstring.h>
 
 #include "store/api/item_handle.h"
 #include "store/api/iterator.h"
@@ -241,7 +241,8 @@
 class SimpleJSONObject : public JSONObject
 {
 protected:
-  ZSTRING_HASH_MAP(csize, Keys);
+  CSTRING_HASH_MAP(csize, Keys);
+
   typedef std::vector<std::pair<store::Item*, store::Item*> > Pairs;
 
   class KeyIterator : public store::Iterator

=== modified file 'src/zorbautils/hashmap.h'
--- src/zorbautils/hashmap.h	2012-09-11 22:55:05 +0000
+++ src/zorbautils/hashmap.h	2012-09-13 20:54:21 +0000
@@ -983,7 +983,7 @@
 };
 
 template <class T, class V, class C>
-const double HashMap<T, V, C>::DEFAULT_LOAD_FACTOR = 0.6;
+const double HashMap<T, V, C>::DEFAULT_LOAD_FACTOR = 0.7;
 
 } // namespace zorba
 


Follow ups