Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Levin Zimmermann
neoppod
Commits
bfeb87e7
Commit
bfeb87e7
authored
Sep 04, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
99b11e6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
1 deletion
+67
-1
go/neo/t/zsha1.go
go/neo/t/zsha1.go
+59
-0
go/neo/t/zsha1.py
go/neo/t/zsha1.py
+8
-1
No files found.
go/neo/t/zsha1.go
0 → 100644
View file @
bfeb87e7
// zsha1 - compute sha1 of whole latest objects stream in a ZODB database
package
main
import
(
"context"
"crypto/sha1"
"log"
"fmt"
"os"
"time"
"lab.nexedi.com/kirr/neo/go/zodb"
_
"lab.nexedi.com/kirr/neo/go/zodb/wks"
)
func
main
()
{
url
:=
os
.
Args
[
1
]
// XXX dirty
bg
:=
context
.
Background
()
stor
,
err
:=
zodb
.
OpenStorageURL
(
bg
,
url
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
lastTid
,
err
:=
stor
.
LastTid
(
bg
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
before
:=
lastTid
+
1
// XXX overflow ?
tstart
:=
time
.
Now
()
m
:=
sha1
.
New
()
oid
:=
zodb
.
Oid
(
0
)
nread
:=
0
loop
:
for
{
xid
:=
zodb
.
Xid
{
Oid
:
oid
,
XTid
:
zodb
.
XTid
{
Tid
:
before
,
TidBefore
:
true
}}
data
,
_
,
err
:=
stor
.
Load
(
bg
,
xid
)
switch
err
.
(
type
)
{
case
nil
:
// ok
case
*
zodb
.
ErrOidMissing
:
break
loop
default
:
log
.
Fatal
(
err
)
}
m
.
Write
(
data
)
nread
+=
len
(
data
)
oid
+=
1
}
tend
:=
time
.
Now
()
fmt
.
Printf
(
"%x ; oid=0..%d nread=%d t=%s
\n
"
,
m
.
Sum
(
nil
),
oid
-
1
,
nread
,
tend
.
Sub
(
tstart
))
}
go/neo/t/zsha1.py
View file @
bfeb87e7
...
@@ -7,6 +7,7 @@ from ZODB.utils import p64, u64
...
@@ -7,6 +7,7 @@ from ZODB.utils import p64, u64
import
hashlib
import
hashlib
import
sys
import
sys
from
time
import
time
def
main
():
def
main
():
url
=
sys
.
argv
[
1
]
url
=
sys
.
argv
[
1
]
...
@@ -15,9 +16,11 @@ def main():
...
@@ -15,9 +16,11 @@ def main():
last_tid
=
stor
.
lastTransaction
()
last_tid
=
stor
.
lastTransaction
()
before
=
p64
(
u64
(
last_tid
)
+
1
)
before
=
p64
(
u64
(
last_tid
)
+
1
)
tstart
=
time
()
m
=
hashlib
.
sha1
()
m
=
hashlib
.
sha1
()
oid
=
0
oid
=
0
nread
=
0
while
1
:
while
1
:
try
:
try
:
data
,
serial
,
_
=
stor
.
loadBefore
(
p64
(
oid
),
before
)
data
,
serial
,
_
=
stor
.
loadBefore
(
p64
(
oid
),
before
)
...
@@ -27,9 +30,13 @@ def main():
...
@@ -27,9 +30,13 @@ def main():
#print('%s @%s' % (oid, u64(serial)))
#print('%s @%s' % (oid, u64(serial)))
m
.
update
(
data
)
m
.
update
(
data
)
nread
+=
len
(
data
)
oid
+=
1
oid
+=
1
print
(
'%s ; oid=0..%d'
%
(
m
.
hexdigest
(),
oid
-
1
))
tend
=
time
()
print
(
'%s ; oid=0..%d nread=%d t=%.3fs'
%
\
(
m
.
hexdigest
(),
oid
-
1
,
nread
,
tend
-
tstart
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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