~zorba-coders/zorba/jsoniq

« back to all changes in this revision

Viewing changes to bin/zorbacmd.cpp

  • Committer: Markos Zaharioudakis
  • Date: 2012-03-08 23:31:02 UTC
  • mfrom: (10524.2.186 zorba)
  • Revision ID: markos_za@yahoo.com-20120308233102-f5o3w0fd7yh7af97
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <zorba/iterator.h>
39
39
#include <zorba/xquery_functions.h>
40
40
#include <zorba/uri_resolvers.h>
 
41
#include <zorba/serialization_callback.h>
41
42
 
42
43
#include <zorba/store_manager.h>
43
44
 
72
73
OneToOneURIMapper theStopWordsMapper(EntityData::STOP_WORDS);
73
74
OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS);
74
75
#endif
 
76
class URIMapperSerializationCallback : public SerializationCallback
 
77
{
 
78
  private:
 
79
    std::vector<URIMapper*> theURIMappers;
 
80
 
 
81
  public:
 
82
    void addURIMapper(URIMapper* lURIMapper)
 
83
    {
 
84
      theURIMappers.push_back(lURIMapper);
 
85
    }
 
86
 
 
87
    virtual URIMapper*
 
88
    getURIMapper(size_t i) const
 
89
    {   
 
90
      return theURIMappers[i];
 
91
    }   
 
92
};
 
93
URIMapperSerializationCallback theSerializationCallback;
75
94
 
76
95
bool
77
96
populateStaticContext(
149
168
    for (; lIter != end; ++lIter) {
150
169
      theStopWordsMapper.addMapping(lIter->uri, lIter->value);
151
170
    }
152
 
    aStaticContext->registerURIMapper(&theStopWordsMapper);
 
171
    if(aProperties.executePlan()) {
 
172
      theSerializationCallback.addURIMapper(&theStopWordsMapper);
 
173
    } else {
 
174
      aStaticContext->registerURIMapper(&theStopWordsMapper);
 
175
    }
153
176
  }
154
177
  {
155
178
    ZorbaCMDProperties::FullText_t::const_iterator lIter = aProperties.thesaurusBegin();
157
180
    for (; lIter != end; ++lIter) {
158
181
      theThesaurusMapper.addMapping(lIter->uri, lIter->value);
159
182
    }
160
 
    aStaticContext->registerURIMapper(&theThesaurusMapper);
 
183
    if(aProperties.executePlan()) {
 
184
      theSerializationCallback.addURIMapper(&theStopWordsMapper);
 
185
    } else {
 
186
      aStaticContext->registerURIMapper(&theThesaurusMapper);
 
187
    }
161
188
  }
162
189
#endif
163
190
  return true;
503
530
  unsigned long lNumExecutions = properties.multiple();
504
531
  bool lIndent = properties.indent();
505
532
  bool doTiming = properties.timing();
506
 
 
 
533
  bool compilePlan = properties.compilePlan();
 
534
  bool executePlan = properties.executePlan();
 
535
  std::ostringstream lOut;
507
536
  Zorba_CompilerHints lHints;
508
537
 
509
538
  // default is O1 in the Zorba_CompilerHints constructor
568
597
        query->registerDiagnosticHandler(&diagnosticHandler);
569
598
        query->setFileName(qfilepath);
570
599
 
571
 
        query->compile(qfile, staticContext, lHints);
 
600
        if(executePlan) {
 
601
          query->loadExecutionPlan(qfile, &theSerializationCallback);
 
602
        } else {
 
603
          query->compile(qfile, staticContext, lHints);
 
604
        }
572
605
 
573
606
        if (doTiming)
574
607
        {
631
664
        }
632
665
        else
633
666
        {
634
 
          query->execute(outputStream, &lSerOptions);
 
667
          if (compilePlan) {
 
668
            query->saveExecutionPlan(outputStream, ZORBA_USE_BINARY_ARCHIVE, SAVE_UNUSED_FUNCTIONS);
 
669
          } else {
 
670
            query->execute(outputStream, &lSerOptions);
 
671
          }
635
672
          if (properties.trailingNl()) {
636
673
            outputStream << std::endl;
637
674
          }