Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Commit message:
fixed bug in usage of document manager inside zorbacmd

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/129049

fixed bug in usage of document manager inside zorbacmd
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/129049
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp	2012-09-19 21:16:15 +0000
+++ bin/zorbacmd.cpp	2012-10-10 21:34:22 +0000
@@ -888,14 +888,23 @@
 
       timing.startTimer(TimingInfo::UNLOAD_TIMER, i);
 
-      DocumentManager* lMgr = store->getDocumentManager();
-      ItemSequence_t lSeq = lMgr->availableDocuments();
-      Iterator_t lIter = lSeq->getIterator();
+      DocumentManager* docMgr = store->getDocumentManager();
+      ItemSequence_t docsSeq = docMgr->availableDocuments();
+      Iterator_t lIter = docsSeq->getIterator();
       lIter->open();
-      Item lURI;
-      while (lIter->next(lURI)) 
-      {
-        lMgr->remove(lURI.getStringValue());
+      Item uri;
+      std::vector<Item> docURIs;
+      while (lIter->next(uri)) 
+      {
+        docURIs.push_back(uri);
+      }
+      lIter->close();
+
+      size_t numDocs = docURIs.size();
+
+      for (size_t k = 0; k < numDocs; ++k)
+      {
+        docMgr->remove(docURIs[k].getStringValue());
       }
 
       timing.stopTimer(TimingInfo::UNLOAD_TIMER, i);

=== modified file 'src/api/documentmanagerimpl.cpp'
--- src/api/documentmanagerimpl.cpp	2012-09-19 21:16:15 +0000
+++ src/api/documentmanagerimpl.cpp	2012-10-10 21:34:22 +0000
@@ -166,9 +166,7 @@
 {
   ZORBA_DM_TRY
   {
-    Item lQName = theFactory->createQName(
-        theDocNamespace,
-        "available-documents");
+    Item lQName = theFactory->createQName(theDocNamespace, "available-documents");
 
     std::vector<ItemSequence_t> lArgs;
 

=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp	2012-10-08 12:09:36 +0000
+++ src/api/staticcontextimpl.cpp	2012-10-10 21:34:22 +0000
@@ -1507,7 +1507,9 @@
     // contains a reference to the query in order to do cleanup work.
     // The same is true for this sctx
     Iterator_t lIter = impl->iterator();
-    return new InvokeItemSequence(impl.release(), lIter, const_cast<StaticContextImpl*>(this));
+    return new InvokeItemSequence(impl.release(),
+                                  lIter,
+                                  const_cast<StaticContextImpl*>(this));
   }
   catch (ZorbaException const& e)
   {

=== modified file 'src/runtime/store/documents_impl.cpp'
--- src/runtime/store/documents_impl.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/store/documents_impl.cpp	2012-10-10 21:34:22 +0000
@@ -210,7 +210,8 @@
 void AvailableDocumentsIteratorState::reset(PlanState& planState)
 {
   PlanIteratorState::reset(planState);
-  if ( theNameIterator != NULL ) {
+  if ( theNameIterator != NULL )
+  {
     theNameIterator->close();
     theNameIterator = NULL;
   }
@@ -225,7 +226,7 @@
   DEFAULT_STACK_INIT(AvailableDocumentsIteratorState, state, aPlanState);
 
   state->theNameIterator = GENV_STORE.getDocumentNames();
-  state->theNameIterator->open ();
+  state->theNameIterator->open();
   while (state->theNameIterator->next(result)) 
   {
     STACK_PUSH( true, state);
@@ -236,6 +237,7 @@
   STACK_END(state);
 }
 
+
 /*******************************************************************************
   declare function
   is-available-document() as xs:boolean

=== modified file 'src/store/naive/document_name_iterator.h'
--- src/store/naive/document_name_iterator.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/document_name_iterator.h	2012-10-10 21:34:22 +0000
@@ -23,66 +23,70 @@
 
   namespace simplestore {
 
-    /*******************************************************************************
-    ********************************************************************************/
-    template < typename T >
-    class DocumentNameIterator : public store::Iterator
-    {
-    private:
-      T&                   theItems;
-      typename T::iterator theIterator;
-      bool                 theOpened;
-    
-    public:
-      DocumentNameIterator(const T& aItems)
-        : theItems(*const_cast<T*>(&aItems)),
-          theOpened(false)
-      {
-      }
-    
-      virtual ~DocumentNameIterator()
-      {
-        close();
-      }
-    
-      virtual void open()
-      {
-        theIterator = theItems.begin();
-        theOpened = true;
-      }
-    
-      virtual bool next(store::Item_t& aResult)
-      {
-        if (theIterator == theItems.end())
-        {
-          aResult = NULL;
-          return false;
-        }
-        else
-        {
-          zstring lUri = (*theIterator).first;
-          GENV_ITEMFACTORY->createString(aResult, lUri);
-          ++theIterator;
-          return true;
-        }
-      }
-    
-      virtual void reset()
-      {
-        theIterator = theItems.begin();
-      }
-    
-      virtual void close()
-      {
-        if (!theOpened) {
-          return;
-        }
-
-        theOpened = false;
-      }
-    };
-
-  } // namespace store
+/*******************************************************************************
+
+********************************************************************************/
+template < typename T >
+class DocumentNameIterator : public store::Iterator
+{
+private:
+  T&                   theItems;
+  typename T::iterator theIterator;
+  bool                 theOpened;
+    
+public:
+  DocumentNameIterator(const T& aItems)
+    :
+    theItems(*const_cast<T*>(&aItems)),
+    theOpened(false)
+  {
+  }
+  
+  virtual ~DocumentNameIterator()
+  {
+    close();
+  }
+    
+  virtual void open()
+  {
+    theIterator = theItems.begin();
+    theOpened = true;
+  }
+    
+  virtual bool next(store::Item_t& aResult)
+  {
+    if (theIterator == theItems.end())
+    {
+      aResult = NULL;
+      return false;
+    }
+    else
+    {
+      zstring lUri = (*theIterator).first;
+      GENV_ITEMFACTORY->createString(aResult, lUri);
+      ++theIterator;
+      return true;
+    }
+  }
+  
+  virtual void reset()
+  {
+    theIterator = theItems.begin();
+  }
+  
+  virtual void close()
+  {
+    if (!theOpened)
+    {
+      return;
+    }
+    
+    theOpened = false;
+  }
+};
+    
+
+} // namespace store
 } // namespace zorba
 
 

=== modified file 'src/zorbaserialization/serialize_basic_types.cpp'
--- src/zorbaserialization/serialize_basic_types.cpp	2012-09-19 21:16:15 +0000
+++ src/zorbaserialization/serialize_basic_types.cpp	2012-10-10 21:34:22 +0000
@@ -377,7 +377,7 @@
   if (ar.is_serializing_out())
   {
      FloatImpl<float> zorba_float(obj);
-    zstring float_str = zorba_float.toString();
+     zstring float_str = zorba_float.toString();
 
     if (isdigit(float_str.c_str()[0]))
     {

-- 
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

Reply via email to