Merge lp:~matthias-brantner/zorba/bug-fixing into lp:zorba

Proposed by Matthias Brantner
Status: Rejected
Rejected by: Matthias Brantner
Proposed branch: lp:~matthias-brantner/zorba/bug-fixing
Merge into: lp:zorba
Diff against target: 192 lines (+79/-15)
5 files modified
doc/zorba/xqddf.dox (+1/-0)
include/zorba/audit.h (+2/-0)
include/zorba/audit_scoped.h (+19/-3)
src/api/auditimpl.cpp (+9/-0)
test/unit/test_audit.cpp (+48/-12)
To merge this branch: bzr merge lp:~matthias-brantner/zorba/bug-fixing
Reviewer Review Type Date Requested Status
Matthias Brantner Pending
Review via email: mp+77630@code.launchpad.net

Commit message

Fix in the XQDDF documentation

Description of the change

Fix in the XQDDF documentation

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/zorba/xqddf.dox'
2--- doc/zorba/xqddf.dox 2011-09-14 06:15:19 +0000
3+++ doc/zorba/xqddf.dox 2011-09-30 02:38:26 +0000
4@@ -1266,6 +1266,7 @@
5 where $art/empid eq $emp/id
6 return $art)
7 return $emp
8+\endcode
9
10 <a name="query_no_probe_3" id="query_no_probe_3"></a>
11 \code
12
13=== modified file 'include/zorba/audit.h'
14--- include/zorba/audit.h 2011-08-19 23:22:48 +0000
15+++ include/zorba/audit.h 2011-09-30 02:38:26 +0000
16@@ -95,6 +95,8 @@
17
18 class ZORBA_DLL_PUBLIC Event {
19 public:
20+ static Event* get();
21+
22 virtual bool audit(const Property&) const = 0;
23 virtual bool audit(const String&) const = 0;
24
25
26=== modified file 'include/zorba/audit_scoped.h'
27--- include/zorba/audit_scoped.h 2011-08-19 23:22:48 +0000
28+++ include/zorba/audit_scoped.h 2011-09-30 02:38:26 +0000
29@@ -28,8 +28,10 @@
30
31 class ZORBA_DLL_PUBLIC ScopedRecord {
32 public:
33- ScopedRecord(Event* event) : theEvent(event), theRecord(0) {
34- assert(event);
35+ ScopedRecord(Event* event)
36+ : theEvent(event ? event : Event::get()),
37+ theRecord(0) {
38+ assert(theEvent);
39 }
40
41 ~ScopedRecord() {
42@@ -104,6 +106,7 @@
43 typedef ScopedAuditor<const int> IntAuditor;
44 typedef ScopedAuditor<zorba::time::Timer> DurationAuditor;
45 typedef ScopedAuditor<zorba::time::Timer, 0x1> TimestampAuditor;
46+ typedef ScopedAuditor<zorba::time::Timer, 0x2> MicroDurationAuditor;
47
48 template<> struct AuditorTraits<const std::string> {
49 typedef const std::string value_type;
50@@ -141,7 +144,7 @@
51 static inline void start(value_type& value) {
52 }
53 static inline audit_type end(value_type& value) {
54- return value;
55+ return static_cast<audit_type>(value);
56 }
57 };
58
59@@ -189,6 +192,19 @@
60 return static_cast<audit_type>(value.getStart());
61 }
62 };
63+
64+ template<> struct AuditorTraits<zorba::time::Timer, 0x2> {
65+ typedef zorba::time::Timer value_type;
66+ typedef long long audit_type;
67+ static inline void start(value_type& value) {
68+ value.start();
69+ }
70+ static inline audit_type end(value_type& value) {
71+ return static_cast<audit_type>(value.elapsed() * 1000);
72+ }
73+
74+ };
75+
76 }
77 }
78 #endif
79
80=== modified file 'src/api/auditimpl.cpp'
81--- src/api/auditimpl.cpp 2011-08-19 23:22:48 +0000
82+++ src/api/auditimpl.cpp 2011-09-30 02:38:26 +0000
83@@ -395,6 +395,15 @@
84 NOPEventImpl NOP_EVENT_IMPL;
85
86 //************************************************************************
87+// Event
88+//************************************************************************
89+
90+Event*
91+Event::get() {
92+ return &NOP_EVENT_IMPL;
93+}
94+
95+//************************************************************************
96 // ProviderImpl
97 //************************************************************************
98
99
100=== modified file 'test/unit/test_audit.cpp'
101--- test/unit/test_audit.cpp 2011-07-28 15:28:16 +0000
102+++ test/unit/test_audit.cpp 2011-09-30 02:38:26 +0000
103@@ -21,14 +21,12 @@
104 #include <zorba/zorba.h>
105 #include <zorba/store_manager.h>
106 #include <zorba/audit.h>
107+#include <zorba/audit_scoped.h>
108
109-int
110-test_audit(int argc, char* argv[])
111+bool
112+test_audit_1(zorba::Zorba* aZorba)
113 {
114- void* store = zorba::StoreManager::getStore();
115- zorba::Zorba* lZorbaInstance = zorba::Zorba::getInstance(store);
116-
117- zorba::audit::Provider* lAuditProvider = lZorbaInstance->getAuditProvider();
118+ zorba::audit::Provider* lAuditProvider = aZorba->getAuditProvider();
119 zorba::audit::Configuration* config = lAuditProvider->createConfiguration();
120 std::vector<zorba::String> property_names;
121 zorba::audit::Configuration::getPropertyNames(property_names);
122@@ -52,8 +50,8 @@
123
124 zorba::audit::Event* event = lAuditProvider->createEvent(config);
125
126- zorba::XQuery_t query = lZorbaInstance->createQuery();
127- zorba::StaticContext_t lStaticContext = lZorbaInstance->createStaticContext();
128+ zorba::XQuery_t query = aZorba->createQuery();
129+ zorba::StaticContext_t lStaticContext = aZorba->createStaticContext();
130
131 lStaticContext->setAuditEvent(event);
132
133@@ -64,7 +62,7 @@
134 query->execute(std::cout, &lSerOptions);
135
136 if (event->size() != 2) {
137- return 1;
138+ return false;
139 } else {
140 // one record for the eval query and one for the main query
141 const zorba::audit::Record* lRecord = event->at(0);
142@@ -74,9 +72,47 @@
143 std::cerr << *event << std::endl;
144 }
145
146-
147- lZorbaInstance->getAuditProvider()->submitEvent(event);
148- lZorbaInstance->getAuditProvider()->destroyConfiguration(config);
149+ aZorba->getAuditProvider()->submitEvent(event);
150+ aZorba->getAuditProvider()->destroyConfiguration(config);
151+
152+ return true;
153+}
154+
155+bool
156+test_audit_2(zorba::Zorba* aZorba)
157+{
158+ zorba::audit::Provider* lAuditProvider = aZorba->getAuditProvider();
159+ zorba::audit::Configuration* config = lAuditProvider->createConfiguration();
160+
161+ {
162+ // test to make sure that auditing doesn't crash if the record is initialized
163+ // with a 0 event pointer
164+ zorba::audit::ScopedRecord sar(0);
165+ zorba::time::Timer lTimer;
166+ zorba::audit::MicroDurationAuditor auditor(sar, "blub", lTimer);
167+ }
168+
169+
170+ aZorba->getAuditProvider()->destroyConfiguration(config);
171+
172+ return true;
173+}
174+
175+int
176+test_audit(int argc, char* argv[])
177+{
178+ void* store = zorba::StoreManager::getStore();
179+ zorba::Zorba* lZorbaInstance = zorba::Zorba::getInstance(store);
180+
181+ if (!test_audit_1(lZorbaInstance))
182+ {
183+ return 1;
184+ }
185+
186+ if (!test_audit_2(lZorbaInstance))
187+ {
188+ return 2;
189+ }
190
191 return 0;
192 }

Subscribers

People subscribed via source and target branches