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
1fb615dc
Commit
1fb615dc
authored
Apr 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X draft of catobj
parent
8cb4e9c0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
6 deletions
+117
-6
go/neo/client.go
go/neo/client.go
+2
-1
go/zodb/zodb.go
go/zodb/zodb.go
+3
-3
go/zodb/zodbtools/catobj.go
go/zodb/zodbtools/catobj.go
+104
-0
go/zodb/zodbtools/command.go
go/zodb/zodbtools/command.go
+2
-1
go/zodb/zodbtools/dump.go
go/zodb/zodbtools/dump.go
+1
-1
go/zodb/zodbtools/help.go
go/zodb/zodbtools/help.go
+5
-0
No files found.
go/neo/client.go
View file @
1fb615dc
...
...
@@ -88,7 +88,7 @@ func openClientByURL(u *url.URL) (zodb.IStorage, error) {
return
nil
,
err
}
// identify ourselves via conn
//
first
identify ourselves via conn
storType
,
err
:=
IdentifyMe
(
storLink
,
CLIENT
)
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx
...
...
@@ -98,6 +98,7 @@ func openClientByURL(u *url.URL) (zodb.IStorage, error) {
return
nil
,
fmt
.
Errorf
(
"%v: peer is not storage (identifies as %v)"
,
storLink
,
storType
)
}
// identification passed
conn
,
err
:=
storLink
.
NewConn
()
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx ?
...
...
go/zodb/zodb.go
View file @
1fb615dc
...
...
@@ -29,13 +29,13 @@ type Tid uint64 // transaction identifier
type
Oid
uint64
// object identifier
// XTid is "extended" transaction identifier. It defines a transaction for
// oid lookup - either exactly by serial, or
<beforeTid XXX
// oid lookup - either exactly by serial, or
by < beforeTid.
type
XTid
struct
{
Tid
TidBefore
bool
// XXX merge into Tid itself (high bit) ?
}
// Xid is "extended" oid = oid + serial/beforeTid, completely specifying object
revision XXX text
// Xid is "extended" oid = oid + serial/beforeTid, completely specifying object
address.
type
Xid
struct
{
XTid
Oid
...
...
@@ -140,7 +140,7 @@ type IStorage interface {
// LoadSerial and LoadBefore generalized into 1 Load (see Xid for details)
// TODO data []byte -> something allocated from slab ?
Load
(
xid
Xid
)
(
data
[]
byte
,
tid
Tid
,
err
error
)
Load
(
xid
Xid
)
(
data
[]
byte
,
tid
Tid
,
err
error
)
// XXX -> StorageRecordInformation ?
// -> Prefetch(xid Xid) ...
// PrefetchBefore(oidv []Oid, beforeTid Tid) error (?)
...
...
go/zodb/zodbtools/catobj.go
0 → 100644
View file @
1fb615dc
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
package
zodbtools
// Catobj - dump content of a database object
import
(
"flag"
"fmt"
"io"
"log"
"os"
"../../zodb"
)
// Catobj dumps content of one ZODB object XXX text
func
Catobj
(
w
io
.
Writer
,
stor
zodb
.
IStorage
,
xid
zodb
.
Xid
)
error
{
var
objInfo
zodb
.
StorageRecordInformation
data
,
tid
,
err
:=
stor
.
Load
(
xid
)
if
err
!=
nil
{
return
err
}
// XXX hack - rework IStorage.Load to fill-in objInfo directly
objInfo
.
Oid
=
xid
.
Oid
objInfo
.
Tid
=
tid
objInfo
.
Data
=
data
objInfo
.
DataTid
=
tid
// XXX wrong
d
:=
dumper
{
W
:
w
}
// XXX HashOnly + raw dump
err
=
d
.
DumpData
(
&
objInfo
)
return
err
}
// ----------------------------------------
const
catobjSummary
=
"dump content of a database object"
func
catobjUsage
(
w
io
.
Writer
)
{
fmt
.
Fprintf
(
w
,
`Usage: zodb catobj [OPTIONS] <storage> xid...
Dump content of a ZODB database object.
<storage> is an URL (see 'zodb help zurl') of a ZODB-storage.
xid is object address (see 'zodb help xid').
Options:
-h --help this help text.
// -hashonly dump only hashes of objects without content. XXX
`
)
}
func
catobjMain
(
argv
[]
string
)
{
flags
:=
flag
.
FlagSet
{
Usage
:
func
()
{
dumpUsage
(
os
.
Stderr
)
}}
flags
.
Init
(
""
,
flag
.
ExitOnError
)
// flags.BoolVar(&hashOnly, "hashonly", hashOnly, "dump only hashes of objects")
flags
.
Parse
(
argv
[
1
:
])
argv
=
flags
.
Args
()
if
len
(
argv
)
<
2
{
flags
.
Usage
()
os
.
Exit
(
2
)
}
storUrl
:=
argv
[
0
]
xidv
:=
[]
zodb
.
Xid
{}
for
_
,
arg
:=
range
argv
[
1
:
]
{
xid
,
err
:=
zodb
.
ParseXid
(
arg
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
// XXX recheck
}
xidv
=
append
(
xidv
,
xid
)
}
stor
,
err
:=
zodb
.
OpenStorageURL
(
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
// TODO defer stor.Close()
for
_
,
xid
:=
range
xidv
{
err
=
Catobj
(
os
.
Stdout
,
stor
,
xid
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
}
}
go/zodb/zodbtools/command.go
View file @
1fb615dc
...
...
@@ -46,6 +46,7 @@ var Commands = CommandRegistry{
// NOTE the order commands are listed here is the order how they will appear in help
// TODO analyze ?
// TODO cmp
{
"dump"
,
dumpSummary
,
dumpUsage
,
dumpMain
},
{
"info"
,
infoSummary
,
infoUsage
,
infoMain
},
{
"dump"
,
dumpSummary
,
dumpUsage
,
dumpMain
},
{
"catobj"
,
catobjSummary
,
catobjUsage
,
catobjMain
},
}
go/zodb/zodbtools/dump.go
View file @
1fb615dc
...
...
@@ -64,6 +64,7 @@ var _LF = []byte{'\n'}
// DumpData dumps one data record
// XXX naming -> DumpObj ?
func
(
d
*
dumper
)
DumpData
(
datai
*
zodb
.
StorageRecordInformation
)
error
{
buf
:=
&
d
.
buf
buf
.
Reset
()
...
...
@@ -235,7 +236,6 @@ func dumpMain(argv []string) {
}
storUrl
:=
argv
[
0
]
if
len
(
argv
)
>
1
{
tidRange
=
argv
[
1
]
}
...
...
go/zodb/zodbtools/help.go
View file @
1fb615dc
...
...
@@ -69,3 +69,8 @@ http://docs.pylonsproject.org/projects/zodburi/
var
HelpTopics
=
HelpRegistry
{
{
"zurl"
,
"specifying database URL"
,
helpZURL
},
}
// TODO xid
// TODO dump format
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