Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
neo
Commits
ac801304
Commit
ac801304
authored
Sep 05, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X found thinko in decompress()
parent
5ef342b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
6 deletions
+51
-6
go/neo/client/util.go
go/neo/client/util.go
+9
-3
go/neo/client/util_test.go
go/neo/client/util_test.go
+33
-0
go/neo/t/t.sh
go/neo/t/t.sh
+1
-1
go/neo/t/zsha1.go
go/neo/t/zsha1.go
+4
-1
go/neo/t/zsha1.py
go/neo/t/zsha1.py
+4
-1
No files found.
go/neo/client/util.go
View file @
ac801304
...
@@ -26,16 +26,22 @@ func lclose(ctx context.Context, c io.Closer) {
...
@@ -26,16 +26,22 @@ func lclose(ctx context.Context, c io.Closer) {
// if out has not not enough capacity a new buffer is allocated and used.
// if out has not not enough capacity a new buffer is allocated and used.
//
//
// return: destination buffer with full decompressed data or error.
// return: destination buffer with full decompressed data or error.
func
decompress
(
in
[]
byte
,
out
[]
byte
)
(
[]
byte
,
error
)
{
func
decompress
(
in
[]
byte
,
out
[]
byte
)
(
data
[]
byte
,
err
error
)
{
bin
:=
bytes
.
NewReader
(
in
)
bin
:=
bytes
.
NewReader
(
in
)
zr
,
err
:=
zlib
.
NewReader
(
bin
)
zr
,
err
:=
zlib
.
NewReader
(
bin
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
defer
zr
.
Close
()
defer
func
()
{
err2
:=
zr
.
Close
()
if
err2
!=
nil
&&
err
==
nil
{
err
=
err2
data
=
nil
}
}()
bout
:=
bytes
.
NewBuffer
(
out
)
bout
:=
bytes
.
NewBuffer
(
out
)
_
,
err
=
io
.
Copy
(
bout
,
bin
)
_
,
err
=
io
.
Copy
(
bout
,
zr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
go/neo/client/util_test.go
0 → 100644
View file @
ac801304
package
client
import
(
"testing"
"github.com/kylelemons/godebug/pretty"
)
var
ztestv
=
[]
struct
{
in
,
out
string
}{
{
in
:
"x
\x9c\xf3
H
\xcd\xc9\xc9
W
\x08\xcf
/
\xca
IQ
\x04\x00\x1c
I
\x04
>"
,
out
:
"Hello World!"
,
},
{
in
:
"x
\x9c
K.H-*
\xce
,.I
\xcd
+
\xd1\xcb
M,(
\xc8\xcc
K
\xe7\n\x80\x0b\xf9
BE
\n\x19\xf5
j
\x0b\x99
BYR
\x12
K
\x12\x0b\x99
k
\x0b
YB
\xd9\x8b
3
\xd3\xf3\x12
s
\xca\n
Y5B9
\x18
\x80\xb1\x90
-
\xb9
<5/%5'3O/)3=
\xb1\xa8
(
\xb1
R
\x0f
L
\xc6
W
\xe5\xa7
$qE9e
\xa6
;
\x82\xb8\\\x85\xec
%
\x81\xc5\xc5
z
\x00\xb0
d)
\xef
"
,
out
:
"cpersistent.mapping
\n
PersistentMapping
\n
q
\x01
.}q
\x02
U
\x04
dataq
\x03
}q
\x04
U
\x07
signalvq
\x05
(U
\x08\x00\x00\x00\x00\x00\x00\x00\x01
q
\x06
cwendelin.bigarray.array_zodb
\n
ZBigArray
\n
q
\x07
tQss."
,
},
}
func
TestDecompress
(
t
*
testing
.
T
)
{
for
_
,
tt
:=
range
ztestv
{
got
,
err
:=
decompress
([]
byte
(
tt
.
in
),
nil
)
if
err
!=
nil
{
t
.
Errorf
(
"decompress err: %q"
,
tt
.
in
)
continue
}
gots
:=
string
(
got
)
if
gots
!=
tt
.
out
{
t
.
Errorf
(
"decompress output mismatch:
\n
%s
\n
"
,
pretty
.
Compare
(
tt
.
out
,
gots
))
}
}
}
go/neo/t/t.sh
View file @
ac801304
...
@@ -208,7 +208,7 @@ gensqlite() {
...
@@ -208,7 +208,7 @@ gensqlite() {
#neopylite
#neopylite
neopysql
neopysql
#time demo-zbigarray read neo://$cluster@$Mbind
#time demo-zbigarray read neo://$cluster@$Mbind
#
./zsha1.py neo://$cluster@$Mbind 2>py.log
./zsha1.py neo://
$cluster
@
$Mbind
2>py.log
go run zsha1.go neo://
$cluster
@
$Mbind
2>go.log
go run zsha1.go neo://
$cluster
@
$Mbind
2>go.log
xneoctl
set
cluster stopping
xneoctl
set
cluster stopping
xmysql
-e
"SHUTDOWN"
xmysql
-e
"SHUTDOWN"
...
...
go/neo/t/zsha1.go
View file @
ac801304
...
@@ -59,13 +59,16 @@ loop:
...
@@ -59,13 +59,16 @@ loop:
m
.
Write
(
data
)
m
.
Write
(
data
)
fmt
.
Fprintf
(
os
.
Stderr
,
"%d @%s
\t
sha1: %x
\n
"
,
uint
(
oid
),
serial
,
m
.
Sum
(
nil
))
fmt
.
Fprintf
(
os
.
Stderr
,
"%d @%s
\t
sha1: %x
\n
"
,
uint
(
oid
),
serial
,
m
.
Sum
(
nil
))
fmt
.
Fprintf
(
os
.
Stderr
,
"
\t
data: %x
\n
"
,
data
)
nread
+=
len
(
data
)
nread
+=
len
(
data
)
oid
+=
1
oid
+=
1
break
}
}
tend
:=
time
.
Now
()
tend
:=
time
.
Now
()
fmt
.
Printf
(
"%x ; oid=0..%d nread=%d t=%s
\n
"
,
fmt
.
Printf
(
"%x ; oid=0..%d nread=%d t=%s
x=zsha1.go
\n
"
,
m
.
Sum
(
nil
),
oid
-
1
,
nread
,
tend
.
Sub
(
tstart
))
m
.
Sum
(
nil
),
oid
-
1
,
nread
,
tend
.
Sub
(
tstart
))
}
}
go/neo/t/zsha1.py
View file @
ac801304
...
@@ -32,13 +32,16 @@ def main():
...
@@ -32,13 +32,16 @@ def main():
m
.
update
(
data
)
m
.
update
(
data
)
print
(
'%s @%s
\
t
sha1: %s'
%
(
oid
,
u64
(
serial
),
m
.
hexdigest
()),
file
=
sys
.
stderr
)
print
(
'%s @%s
\
t
sha1: %s'
%
(
oid
,
u64
(
serial
),
m
.
hexdigest
()),
file
=
sys
.
stderr
)
print
(
'
\
t
data: %s'
%
(
data
.
encode
(
'hex'
),),
file
=
sys
.
stderr
)
nread
+=
len
(
data
)
nread
+=
len
(
data
)
oid
+=
1
oid
+=
1
break
tend
=
time
()
tend
=
time
()
print
(
'%s ; oid=0..%d nread=%d t=%.3fs'
%
\
print
(
'%s ; oid=0..%d nread=%d t=%.3fs
x=zsha1.py
'
%
\
(
m
.
hexdigest
(),
oid
-
1
,
nread
,
tend
-
tstart
))
(
m
.
hexdigest
(),
oid
-
1
,
nread
,
tend
-
tstart
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment