← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~juan457/zorba/xqxq-api-changes into lp:zorba

 

Juan Zacarias has proposed merging lp:~juan457/zorba/xqxq-api-changes into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~juan457/zorba/xqxq-api-changes/+merge/79589

C++ API changes:

Implementation of getExternalVariables function

Implementation of isSequential function
-- 
https://code.launchpad.net/~juan457/zorba/xqxq-api-changes/+merge/79589
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/dynamic_context.h'
--- include/zorba/dynamic_context.h	2011-10-03 09:18:49 +0000
+++ include/zorba/dynamic_context.h	2011-10-17 17:53:26 +0000
@@ -43,6 +43,15 @@
 class ZORBA_DLL_PUBLIC DynamicContext
 {
  public:
+  /** \brief Returns a vector with the Qname of variables not 
+   *         bound to the dynamic context.
+   *
+   * @param aVars variable to store the results.
+   * @throw ZorbaException if an error occured.
+   */
+  virtual bool
+  getExternalVariables(std::vector<Item>& aVars) const = 0;
+	 
   /**
    * \brief Defines the external variable identified by aQName and assigns it
    * the value of aItem.
@@ -261,7 +270,6 @@
    */
   virtual ExternalFunctionParameter*
   getExternalFunctionParameter ( const String& aName ) const = 0;
-  
 
 protected:
   /** \brief Destructor

=== modified file 'include/zorba/xquery.h'
--- include/zorba/xquery.h	2011-07-25 17:40:50 +0000
+++ include/zorba/xquery.h	2011-10-17 17:53:26 +0000
@@ -315,7 +315,18 @@
    */
   virtual bool
   isUpdating() const = 0;
-  
+  
+   /** 
+   * \brief Check if this query is a sequential query.
+   *
+   * @return true if the query is a sequential query, false otherwise.
+   * @throw SystemException if the query is not compiled or has been closed.
+   * @see close()
+   * @see compile(...)
+   */
+  virtual bool 
+  isSequential() const = 0;
+
   /** \brief Save the compiled execution plan.
    *
    * After compiling an XQuery program you can save the execution plan in some

=== modified file 'src/api/dynamiccontextimpl.cpp'
--- src/api/dynamiccontextimpl.cpp	2011-10-03 09:18:49 +0000
+++ src/api/dynamiccontextimpl.cpp	2011-10-17 17:53:26 +0000
@@ -182,6 +182,42 @@
   return var;
 }
 
+/****************************************************************************//**
+
+********************************************************************************/
+
+bool DynamicContextImpl::getExternalVariables(
+  std::vector<Item>& aVars
+  ) const 
+{
+  
+  ZORBA_DCTX_TRY
+  {
+    //get all the local variables to check them later
+    std::vector<var_expr_t> lVars;
+    theStaticContext->getVariables(lVars, true);
+    
+    std::vector<var_expr_t>::iterator lIte = lVars.begin();
+    std::vector<var_expr_t>::iterator lEnd = lVars.end();
+    
+    for (; lIte != lEnd; ++lIte) 
+    { 
+          
+      if(lIte->getp()->is_external())
+        aVars.push_back(lIte->getp()->get_name());
+            
+    }
+    
+    if(!aVars.empty())
+      return true;
+       
+  }
+  ZORBA_DCTX_CATCH
+  
+  return false;
+}
+
+
 
 /****************************************************************************//**
 

=== modified file 'src/api/dynamiccontextimpl.h'
--- src/api/dynamiccontextimpl.h	2011-10-03 09:18:49 +0000
+++ src/api/dynamiccontextimpl.h	2011-10-17 17:53:26 +0000
@@ -82,6 +82,10 @@
 
 public:
   virtual bool
+  getExternalVariables(
+      std::vector<Item>& aVars)const;
+
+  virtual bool
   getVariable(
       const String& inNamespace,
       const String& inLocalname,

=== modified file 'src/api/xqueryimpl.cpp'
--- src/api/xqueryimpl.cpp	2011-09-14 11:08:52 +0000
+++ src/api/xqueryimpl.cpp	2011-10-17 17:53:26 +0000
@@ -771,6 +771,24 @@
 
 
 /*******************************************************************************
+ Return true, if the root expr of the query is a sequential expr.
+********************************************************************************/
+bool XQueryImpl::isSequential() const
+{
+  SYNC_CODE(AutoMutex lock(&theMutex);)
+
+  try
+  {
+    checkNotClosed();
+    checkCompiled();
+
+    return theCompilerCB->isSequential();
+  }
+  QUERY_CATCH
+  return false;
+}
+
+/*******************************************************************************
   Serialize the execution plan inot the given output stream.
 ********************************************************************************/
 bool XQueryImpl::saveExecutionPlan(

=== modified file 'src/api/xqueryimpl.h'
--- src/api/xqueryimpl.h	2011-09-14 11:08:52 +0000
+++ src/api/xqueryimpl.h	2011-10-17 17:53:26 +0000
@@ -285,6 +285,8 @@
   const StaticContext* getStaticContext() const;
 
   bool isUpdating() const;
+  
+  bool isSequential() const;
 
   bool saveExecutionPlan(
         std::ostream& os,

=== modified file 'src/compiler/api/compilercb.cpp'
--- src/compiler/api/compilercb.cpp	2011-06-14 17:26:33 +0000
+++ src/compiler/api/compilercb.cpp	2011-10-17 17:53:26 +0000
@@ -114,6 +114,7 @@
   theIsEval(false),
   theIsLoadProlog(false),
   theIsUpdating(false),
+  theIsSequential(false),
   theTimeout(timeout),
   theTempIndexCounter(0)
 {

=== modified file 'src/compiler/api/compilercb.h'
--- src/compiler/api/compilercb.h	2011-06-14 17:26:33 +0000
+++ src/compiler/api/compilercb.h	2011-10-17 17:53:26 +0000
@@ -155,6 +155,8 @@
 
   bool                      theIsUpdating;
 
+  bool                      theIsSequential;
+
   long                      theTimeout;
 
   ulong                     theTempIndexCounter;
@@ -181,6 +183,10 @@
 
   bool isUpdating() const { return theIsUpdating; }
 
+  void setIsSequential(bool aIsSequential) {theIsSequential = aIsSequential;}
+
+  bool isSequential() const { return theIsSequential;}
+
   static_context* getStaticContext(short id);
 };
 

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2011-10-03 09:18:49 +0000
+++ src/compiler/translator/translator.cpp	2011-10-17 17:53:26 +0000
@@ -5190,6 +5190,11 @@
     theModulesInfo->theCCB->setIsUpdating(true);
   }
 
+  if(program ->is_sequential())
+  {
+    theModulesInfo->theCCB->setIsSequential(true);
+  }
+
   if (program->is_updating() && !theCCB->theIsEval)
   {
     program = new apply_expr(theRootSctx,

=== modified file 'src/context/dynamic_context.h'
--- src/context/dynamic_context.h	2011-10-03 09:18:49 +0000
+++ src/context/dynamic_context.h	2011-10-17 17:53:26 +0000
@@ -163,6 +163,7 @@
       const store::Item_t& varname,
       const QueryLoc& loc);
 
+
   void get_variable(
         ulong varid,
         const store::Item_t& varname,


Follow ups