Merge lp:~niemeyer/gozk/int32-to-int into lp:gozk/zookeeper

Proposed by Gustavo Niemeyer
Status: Merged
Merged at revision: 28
Proposed branch: lp:~niemeyer/gozk/int32-to-int
Merge into: lp:gozk/zookeeper
Diff against target: 287 lines (+39/-39)
3 files modified
retry_test.go (+14/-14)
zk.go (+13/-13)
zk_test.go (+12/-12)
To merge this branch: bzr merge lp:~niemeyer/gozk/int32-to-int
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+93252@code.launchpad.net

Description of the change

Use int32 rather than int for stat fields.

https://codereview.appspot.com/5675059/

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Please take a look.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :
Download full text (9.7 KiB)

Reviewers: mp+93252_code.launchpad.net,

Message:
Please take a look.

Description:

https://code.launchpad.net/~niemeyer/gozk/int32-to-int/+merge/93252

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/5675059/

Affected files:
   M retry_test.go
   M zk.go
   M zk_test.go

Index: retry_test.go
=== <email address hidden> >
<email address hidden>
=== modified file 'retry_test.go'
--- retry_test.go 2011-11-29 17:44:18 +0000
+++ retry_test.go 2012-02-15 17:18:34 +0000
@@ -20,7 +20,7 @@
   data, stat, err := conn.Get("/test")
   c.Assert(err, IsNil)
   c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(0))
+ c.Assert(stat.Version(), Equals, 0)
   c.Assert(data, Equals, "new")

   acl, _, err := conn.ACL("/test")
@@ -38,7 +38,7 @@
    func(data string, stat *zk.Stat) (string, error) {
     c.Assert(data, Equals, "old")
     c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(0))
+ c.Assert(stat.Version(), Equals, 0)
     return "brand new", nil
    })
   c.Assert(err, IsNil)
@@ -46,7 +46,7 @@
   data, stat, err := conn.Get("/test")
   c.Assert(err, IsNil)
   c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(1))
+ c.Assert(stat.Version(), Equals, 1)
   c.Assert(data, Equals, "brand new")

   // ACL was unchanged by RetryChange().
@@ -65,7 +65,7 @@
    func(data string, stat *zk.Stat) (string, error) {
     c.Assert(data, Equals, "old")
     c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(0))
+ c.Assert(stat.Version(), Equals, 0)
     return "old", nil
    })
   c.Assert(err, IsNil)
@@ -73,7 +73,7 @@
   data, stat, err := conn.Get("/test")
   c.Assert(err, IsNil)
   c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(0)) // Unchanged!
+ c.Assert(stat.Version(), Equals, 0) // Unchanged!
   c.Assert(data, Equals, "old")
  }

@@ -90,7 +90,7 @@
     return "<none> => conflict", nil
    case "conflict":
     c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(0))
+ c.Assert(stat.Version(), Equals, 0)
     return "conflict => new", nil
    default:
     c.Fatal("Unexpected node data: " + data)
@@ -105,7 +105,7 @@
   c.Assert(err, IsNil)
   c.Assert(data, Equals, "conflict => new")
   c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(1))
+ c.Assert(stat.Version(), Equals, 1)
  }

  func (s *S) TestRetryChangeConflictOnSetDueToChange(c *C) {
@@ -118,13 +118,13 @@
    switch data {
    case "old":
     c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(0))
+ c.Assert(stat.Version(), Equals, 0)
     _, err := conn.Set("/test", "conflict", 0)
     c.Assert(err, IsNil)
     return "old => new", nil
    case "conflict":
     c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(1))
+ c.Assert(stat.Version(), Equals, 1)
     return "conflict => new", nil
    default:
     c.Fatal("Unexpected node data: " + data)
@@ -139,7 +139,7 @@
   c.Assert(err, IsNil)
   c.Assert(data, Equals, "conflict => new")
   c.Assert(stat, NotNil)
- c.Assert(stat.Version(), Equals, int32(2))
+ c.Assert(stat.Version(), Equals, 2)
  }

 ...

Read more...

Revision history for this message
William Reade (fwereade) wrote :
Revision history for this message
Roger Peppe (rogpeppe) wrote :
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

*** Submitted:

Use int32 rather than int for stat fields.

R=fwereade, TheMue, rog
CC=
https://codereview.appspot.com/5675059

https://codereview.appspot.com/5675059/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'retry_test.go'
2--- retry_test.go 2011-11-29 17:44:18 +0000
3+++ retry_test.go 2012-02-15 17:54:16 +0000
4@@ -20,7 +20,7 @@
5 data, stat, err := conn.Get("/test")
6 c.Assert(err, IsNil)
7 c.Assert(stat, NotNil)
8- c.Assert(stat.Version(), Equals, int32(0))
9+ c.Assert(stat.Version(), Equals, 0)
10 c.Assert(data, Equals, "new")
11
12 acl, _, err := conn.ACL("/test")
13@@ -38,7 +38,7 @@
14 func(data string, stat *zk.Stat) (string, error) {
15 c.Assert(data, Equals, "old")
16 c.Assert(stat, NotNil)
17- c.Assert(stat.Version(), Equals, int32(0))
18+ c.Assert(stat.Version(), Equals, 0)
19 return "brand new", nil
20 })
21 c.Assert(err, IsNil)
22@@ -46,7 +46,7 @@
23 data, stat, err := conn.Get("/test")
24 c.Assert(err, IsNil)
25 c.Assert(stat, NotNil)
26- c.Assert(stat.Version(), Equals, int32(1))
27+ c.Assert(stat.Version(), Equals, 1)
28 c.Assert(data, Equals, "brand new")
29
30 // ACL was unchanged by RetryChange().
31@@ -65,7 +65,7 @@
32 func(data string, stat *zk.Stat) (string, error) {
33 c.Assert(data, Equals, "old")
34 c.Assert(stat, NotNil)
35- c.Assert(stat.Version(), Equals, int32(0))
36+ c.Assert(stat.Version(), Equals, 0)
37 return "old", nil
38 })
39 c.Assert(err, IsNil)
40@@ -73,7 +73,7 @@
41 data, stat, err := conn.Get("/test")
42 c.Assert(err, IsNil)
43 c.Assert(stat, NotNil)
44- c.Assert(stat.Version(), Equals, int32(0)) // Unchanged!
45+ c.Assert(stat.Version(), Equals, 0) // Unchanged!
46 c.Assert(data, Equals, "old")
47 }
48
49@@ -90,7 +90,7 @@
50 return "<none> => conflict", nil
51 case "conflict":
52 c.Assert(stat, NotNil)
53- c.Assert(stat.Version(), Equals, int32(0))
54+ c.Assert(stat.Version(), Equals, 0)
55 return "conflict => new", nil
56 default:
57 c.Fatal("Unexpected node data: " + data)
58@@ -105,7 +105,7 @@
59 c.Assert(err, IsNil)
60 c.Assert(data, Equals, "conflict => new")
61 c.Assert(stat, NotNil)
62- c.Assert(stat.Version(), Equals, int32(1))
63+ c.Assert(stat.Version(), Equals, 1)
64 }
65
66 func (s *S) TestRetryChangeConflictOnSetDueToChange(c *C) {
67@@ -118,13 +118,13 @@
68 switch data {
69 case "old":
70 c.Assert(stat, NotNil)
71- c.Assert(stat.Version(), Equals, int32(0))
72+ c.Assert(stat.Version(), Equals, 0)
73 _, err := conn.Set("/test", "conflict", 0)
74 c.Assert(err, IsNil)
75 return "old => new", nil
76 case "conflict":
77 c.Assert(stat, NotNil)
78- c.Assert(stat.Version(), Equals, int32(1))
79+ c.Assert(stat.Version(), Equals, 1)
80 return "conflict => new", nil
81 default:
82 c.Fatal("Unexpected node data: " + data)
83@@ -139,7 +139,7 @@
84 c.Assert(err, IsNil)
85 c.Assert(data, Equals, "conflict => new")
86 c.Assert(stat, NotNil)
87- c.Assert(stat.Version(), Equals, int32(2))
88+ c.Assert(stat.Version(), Equals, 2)
89 }
90
91 func (s *S) TestRetryChangeConflictOnSetDueToDelete(c *C) {
92@@ -152,7 +152,7 @@
93 switch data {
94 case "old":
95 c.Assert(stat, NotNil)
96- c.Assert(stat.Version(), Equals, int32(0))
97+ c.Assert(stat.Version(), Equals, 0)
98 err := conn.Delete("/test", 0)
99 c.Assert(err, IsNil)
100 return "old => <deleted>", nil
101@@ -172,7 +172,7 @@
102 c.Assert(err, IsNil)
103 c.Assert(data, Equals, "<deleted> => new")
104 c.Assert(stat, NotNil)
105- c.Assert(stat.Version(), Equals, int32(0))
106+ c.Assert(stat.Version(), Equals, 0)
107
108 // Should be the new ACL.
109 acl, _, err := conn.ACL("/test")
110@@ -214,7 +214,7 @@
111 stat, err := conn.Exists("/test")
112 c.Assert(err, IsNil)
113 c.Assert(stat, NotNil)
114- c.Assert(stat.Version(), Equals, int32(0))
115+ c.Assert(stat.Version(), Equals, 0)
116
117 c.Assert(called, Equals, false)
118 }
119@@ -237,7 +237,7 @@
120 stat, err := conn.Exists("/test")
121 c.Assert(err, IsNil)
122 c.Assert(stat, NotNil)
123- c.Assert(stat.Version(), Equals, int32(0))
124+ c.Assert(stat.Version(), Equals, 0)
125
126 c.Assert(called, Equals, true)
127 }
128
129=== modified file 'zk.go'
130--- zk.go 2012-02-13 14:47:46 +0000
131+++ zk.go 2012-02-15 17:54:16 +0000
132@@ -331,19 +331,19 @@
133 }
134
135 // Version returns the number of changes to the data of the node.
136-func (stat *Stat) Version() int32 {
137- return int32(stat.c.version)
138+func (stat *Stat) Version() int {
139+ return int(stat.c.version)
140 }
141
142 // CVersion returns the number of changes to the children of the node.
143 // This only changes when children are created or removed.
144-func (stat *Stat) CVersion() int32 {
145- return int32(stat.c.cversion)
146+func (stat *Stat) CVersion() int {
147+ return int(stat.c.cversion)
148 }
149
150 // AVersion returns the number of changes to the ACL of the node.
151-func (stat *Stat) AVersion() int32 {
152- return int32(stat.c.aversion)
153+func (stat *Stat) AVersion() int {
154+ return int(stat.c.aversion)
155 }
156
157 // If the node is an ephemeral node, EphemeralOwner returns the session id
158@@ -353,13 +353,13 @@
159 }
160
161 // DataLength returns the length of the data in the node in bytes.
162-func (stat *Stat) DataLength() int32 {
163- return int32(stat.c.dataLength)
164+func (stat *Stat) DataLength() int {
165+ return int(stat.c.dataLength)
166 }
167
168 // NumChildren returns the number of children of the node.
169-func (stat *Stat) NumChildren() int32 {
170- return int32(stat.c.numChildren)
171+func (stat *Stat) NumChildren() int {
172+ return int(stat.c.numChildren)
173 }
174
175 // Pzxid returns the Pzxid of the node, whatever that is.
176@@ -657,7 +657,7 @@
177 //
178 // It is an error to attempt to set the data of a non-existing node with
179 // this function. In these cases, use Create instead.
180-func (conn *Conn) Set(path, value string, version int32) (stat *Stat, err error) {
181+func (conn *Conn) Set(path, value string, version int) (stat *Stat, err error) {
182
183 cpath := C.CString(path)
184 cvalue := C.CString(value)
185@@ -677,7 +677,7 @@
186 // Delete removes the node at path. If version is not -1, the operation
187 // will only succeed if the node is still at this version when the
188 // node is deleted as an atomic operation.
189-func (conn *Conn) Delete(path string, version int32) (err error) {
190+func (conn *Conn) Delete(path string, version int) (err error) {
191 cpath := C.CString(path)
192 defer C.free(unsafe.Pointer(cpath))
193 rc, cerr := C.zoo_delete(conn.handle, cpath, C.int(version))
194@@ -732,7 +732,7 @@
195 }
196
197 // SetACL changes the access control list for path.
198-func (conn *Conn) SetACL(path string, aclv []ACL, version int32) error {
199+func (conn *Conn) SetACL(path string, aclv []ACL, version int) error {
200
201 cpath := C.CString(path)
202 defer C.free(unsafe.Pointer(cpath))
203
204=== modified file 'zk_test.go'
205--- zk_test.go 2012-02-13 14:47:46 +0000
206+++ zk_test.go 2012-02-15 17:54:16 +0000
207@@ -142,12 +142,12 @@
208 c.Assert(stat.Mzxid(), Equals, int64(0))
209 c.Assert(stat.CTime(), Equals, time.Unix(0, 0))
210 c.Assert(stat.MTime(), Equals, time.Unix(0, 0))
211- c.Assert(stat.Version(), Equals, int32(0))
212- c.Assert(stat.CVersion(), Equals, int32(0))
213- c.Assert(stat.AVersion(), Equals, int32(0))
214+ c.Assert(stat.Version(), Equals, 0)
215+ c.Assert(stat.CVersion(), Equals, 0)
216+ c.Assert(stat.AVersion(), Equals, 0)
217 c.Assert(stat.EphemeralOwner(), Equals, int64(0))
218- c.Assert(stat.DataLength(), Equals, int32(0))
219- c.Assert(stat.NumChildren(), Equals, int32(1))
220+ c.Assert(stat.DataLength(), Equals, 0)
221+ c.Assert(stat.NumChildren(), Equals, 1)
222 c.Assert(stat.Pzxid(), Equals, int64(0))
223 }
224
225@@ -201,7 +201,7 @@
226 start = time.Now()
227 stat, err = conn.Set("/test", "bababum", -1) // Any version.
228 c.Assert(err, IsNil)
229- c.Assert(stat.Version(), Equals, int32(1))
230+ c.Assert(stat.Version(), Equals, 1)
231 checkTimeBetween(c, "mtime", stat.MTime(), start, time.Now())
232
233 data, _, err := conn.Get("/test")
234@@ -222,7 +222,7 @@
235 data, stat, watch, err := conn.GetW("/test")
236 c.Assert(err, IsNil)
237 c.Assert(data, Equals, "one")
238- c.Assert(stat.Version(), Equals, int32(0))
239+ c.Assert(stat.Version(), Equals, 0)
240
241 select {
242 case <-watch:
243@@ -313,7 +313,7 @@
244 children, stat, err := conn.Children("/")
245 c.Assert(err, IsNil)
246 c.Assert(children, Equals, []string{"zookeeper"})
247- c.Assert(stat.NumChildren(), Equals, int32(1))
248+ c.Assert(stat.NumChildren(), Equals, 1)
249
250 children, stat, err = conn.Children("/non-existent")
251 c.Assert(err, Equals, zk.ZNONODE)
252@@ -331,7 +331,7 @@
253 children, stat, watch, err := conn.ChildrenW("/")
254 c.Assert(err, IsNil)
255 c.Assert(children, Equals, []string{"zookeeper"})
256- c.Assert(stat.NumChildren(), Equals, int32(1))
257+ c.Assert(stat.NumChildren(), Equals, 1)
258
259 select {
260 case <-watch:
261@@ -352,7 +352,7 @@
262
263 children, stat, watch, err = conn.ChildrenW("/")
264 c.Assert(err, IsNil)
265- c.Assert(stat.NumChildren(), Equals, int32(2))
266+ c.Assert(stat.NumChildren(), Equals, 2)
267
268 // The ordering is most likely unstable, so this test must be fixed.
269 c.Assert(children, Equals, []string{"test1", "zookeeper"})
270@@ -432,7 +432,7 @@
271 stat, watch, err = conn.ExistsW("/test")
272 c.Assert(err, IsNil)
273 c.Assert(stat, NotNil)
274- c.Assert(stat.NumChildren(), Equals, int32(0))
275+ c.Assert(stat.NumChildren(), Equals, 0)
276
277 c.Check(zk.CountPendingWatches(), Equals, 2)
278 }
279@@ -513,7 +513,7 @@
280 c.Assert(err, IsNil)
281 c.Assert(acl, Equals, zk.WorldACL(zk.PERM_ALL))
282 c.Assert(stat, NotNil)
283- c.Assert(stat.Version(), Equals, int32(0))
284+ c.Assert(stat.Version(), Equals, 0)
285
286 acl, stat, err = conn.ACL("/non-existent")
287 c.Assert(err, NotNil)

Subscribers

People subscribed via source and target branches