Merge lp:~zorba-coders/zorba/unregister-delete-or-destroy into lp:zorba

Proposed by Ghislain Fourny
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10750
Merged at revision: 10910
Proposed branch: lp:~zorba-coders/zorba/unregister-delete-or-destroy
Merge into: lp:zorba
Diff against target: 201 lines (+85/-5)
6 files modified
src/store/naive/node_items.cpp (+38/-2)
src/store/naive/node_items.h (+6/-0)
src/store/naive/pul_primitives.cpp (+3/-0)
src/store/naive/simple_store.cpp (+29/-1)
src/store/naive/simple_store.h (+3/-1)
src/store/naive/store.h (+6/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/unregister-delete-or-destroy
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Matthias Brantner Approve
Review via email: mp+100814@code.launchpad.net

Commit message

Differentiating between two reasons why references are unregistered.

Description of the change

Differentiating between two reasons why references are unregistered.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

No approved revision specified.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/unregister-delete-or-destroy into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job unregister-delete-or-destroy-2012-04-04T16-12-59.472Z
  is finished. The final status was:

  71 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/unregister-delete-or-destroy into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job unregister-delete-or-destroy-2012-06-20T16-08-59.225Z
  is finished. The final status was:

  87 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job unregister-delete-or-destroy-2012-06-21T09-46-00.606Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Pending.

Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

This doesn't make sense to me at all!

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Needs Fixing
Revision history for this message
Ghislain Fourny (gislenius) wrote :

Thanks Markos, the function is now virtual ;-)

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job unregister-delete-or-destroy-2012-07-03T09-39-05.169Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Needs Fixing.

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job unregister-delete-or-destroy-2012-07-03T15-05-59.471Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/store/naive/node_items.cpp'
2--- src/store/naive/node_items.cpp 2012-06-29 18:19:56 +0000
3+++ src/store/naive/node_items.cpp 2012-07-03 09:40:26 +0000
4@@ -144,7 +144,7 @@
5 /*******************************************************************************
6
7 ********************************************************************************/
8-void XmlTree::free()
9+void XmlTree::destroy() throw()
10 {
11 // std::cout << "Deleting Xml Tree: " << this << std::endl;
12
13@@ -171,6 +171,15 @@
14 }
15
16
17+/*******************************************************************************
18+
19+********************************************************************************/
20+void XmlTree::free()
21+{
22+ destroy();
23+}
24+
25+
26 #ifndef EMBEDED_TYPE
27
28 /*******************************************************************************
29@@ -880,11 +889,21 @@
30 #endif
31
32 if (haveReference())
33- GET_STORE().unregisterNode(this);
34+ GET_STORE().unregisterReferenceToUnusedNode(this);
35
36 delete this;
37 }
38
39+/*******************************************************************************
40+
41+********************************************************************************/
42+void XmlNode::unregisterReferencesToDeletedSubtree()
43+{
44+ if (haveReference())
45+ GET_STORE().unregisterReferenceToDeletedNode(this);
46+}
47+
48+
49
50 /////////////////////////////////////////////////////////////////////////////////
51 // //
52@@ -1723,6 +1742,23 @@
53 }
54
55
56+/*******************************************************************************
57+
58+********************************************************************************/
59+void InternalNode::unregisterReferencesToDeletedSubtree()
60+{
61+ std::for_each(
62+ childrenBegin(), childrenEnd(),
63+ std::mem_fun(&XmlNode::unregisterReferencesToDeletedSubtree));
64+
65+ std::for_each(
66+ attrsBegin(), attrsEnd(),
67+ std::mem_fun(&XmlNode::unregisterReferencesToDeletedSubtree));
68+
69+ XmlNode::unregisterReferencesToDeletedSubtree();
70+}
71+
72+
73 /////////////////////////////////////////////////////////////////////////////////
74 // //
75 // class DocumentNode //
76
77=== modified file 'src/store/naive/node_items.h'
78--- src/store/naive/node_items.h 2012-06-29 18:19:56 +0000
79+++ src/store/naive/node_items.h 2012-07-03 09:40:26 +0000
80@@ -189,6 +189,8 @@
81
82 void free();
83
84+ void destroy() throw();
85+
86 long getRefCount() const { return theRefCount; }
87
88 long& getRefCount() { return theRefCount; }
89@@ -545,6 +547,8 @@
90
91 bool isConnectorNode() const { return (theFlags & IsConnectorNode) != 0; }
92
93+ virtual void unregisterReferencesToDeletedSubtree();
94+
95 #ifndef ZORBA_NO_FULL_TEXT
96 FTTokenIterator_t getTokens(
97 TokenizerProvider const&,
98@@ -831,6 +835,8 @@
99
100 void finalizeNode();
101
102+ virtual void unregisterReferencesToDeletedSubtree();
103+
104 protected:
105 csize findChild(const XmlNode* child) const;
106
107
108=== modified file 'src/store/naive/pul_primitives.cpp'
109--- src/store/naive/pul_primitives.cpp 2012-06-28 04:14:03 +0000
110+++ src/store/naive/pul_primitives.cpp 2012-07-03 09:40:26 +0000
111@@ -163,6 +163,9 @@
112 {
113 theParent->deleteChild(*this);
114 }
115+
116+ static_cast<zorba::simplestore::XmlNode*>(theTarget.getp())
117+ ->unregisterReferencesToDeletedSubtree();
118 }
119
120
121
122=== modified file 'src/store/naive/simple_store.cpp'
123--- src/store/naive/simple_store.cpp 2012-06-28 21:54:08 +0000
124+++ src/store/naive/simple_store.cpp 2012-07-03 09:40:26 +0000
125@@ -363,7 +363,7 @@
126 @param node XDM node
127 @return whether the node was registered or not.
128 ********************************************************************************/
129-bool SimpleStore::unregisterNode(XmlNode* node)
130+bool SimpleStore::unregisterReferenceToUnusedNode(XmlNode* node)
131 {
132 if (!node->haveReference())
133 return false;
134@@ -386,6 +386,34 @@
135 }
136 }
137
138+/*******************************************************************************
139+ Does nothing in the simple store.
140+
141+ @param node XDM node
142+ @return whether the node was registered or not.
143+********************************************************************************/
144+bool SimpleStore::unregisterReferenceToDeletedNode(XmlNode* node)
145+{
146+ // Does nothing, since there is no persistency layer. A deleted node can still
147+ // be retrieved with a reference, so its reference may not be removed from the
148+ // cache.
149+ // Merely returns true if entry found, false otherwise.
150+
151+ if (!node->haveReference())
152+ return false;
153+
154+ NodeRefMap::iterator resIt;
155+
156+ if ((resIt = theNodeToReferencesMap.find(node)) != theNodeToReferencesMap.end())
157+ {
158+ return true;
159+ }
160+ else
161+ {
162+ return false;
163+ }
164+}
165+
166
167 #ifdef ZORBA_WITH_JSON
168 /*******************************************************************************
169
170=== modified file 'src/store/naive/simple_store.h'
171--- src/store/naive/simple_store.h 2012-06-28 21:54:08 +0000
172+++ src/store/naive/simple_store.h 2012-07-03 09:40:26 +0000
173@@ -98,7 +98,9 @@
174
175 void destroyTreeIdGeneratorFactory(TreeIdGeneratorFactory* g) const;
176
177- bool unregisterNode(XmlNode* node);
178+ bool unregisterReferenceToUnusedNode(XmlNode* node);
179+
180+ bool unregisterReferenceToDeletedNode(XmlNode* node);
181
182 //
183 // Store api methods
184
185=== modified file 'src/store/naive/store.h'
186--- src/store/naive/store.h 2012-06-28 04:14:03 +0000
187+++ src/store/naive/store.h 2012-07-03 09:40:26 +0000
188@@ -418,7 +418,12 @@
189
190 virtual bool getNodeByReference(store::Item_t& result, const zstring& ref) = 0;
191
192- virtual bool unregisterNode(XmlNode* node) = 0;
193+ // Unregisters a reference to an unused node (upon its destruction in
194+ // the memory).
195+ virtual bool unregisterReferenceToUnusedNode(XmlNode* node) = 0;
196+
197+ // Unregisters a reference to a node that was deleted (by XQUF).
198+ virtual bool unregisterReferenceToDeletedNode(XmlNode* node) = 0;
199
200 /*----------------------- Temp Sequence Management ---------------------------*/
201 public:

Subscribers

People subscribed via source and target branches