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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
7429c8ba
Commit
7429c8ba
authored
Jan 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e1f92e97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
12 deletions
+40
-12
t/neo/marshal.go
t/neo/marshal.go
+9
-6
t/neo/protogen.go
t/neo/protogen.go
+31
-6
No files found.
t/neo/marshal.go
View file @
7429c8ba
...
@@ -400,6 +400,7 @@ overflow:
...
@@ -400,6 +400,7 @@ overflow:
// 9. AcceptIdentification
// 9. AcceptIdentification
func
(
p
*
AcceptIdentification
)
NEOEncodedLen
()
int
{
func
(
p
*
AcceptIdentification
)
NEOEncodedLen
()
int
{
var
size
int
size
+=
30
size
+=
30
for
i
:=
0
;
i
<
len
(
p
.
KnownMasterList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
KnownMasterList
);
i
++
{
a
:=
&
p
.
KnownMasterList
[
i
]
a
:=
&
p
.
KnownMasterList
[
i
]
...
@@ -721,6 +722,7 @@ overflow:
...
@@ -721,6 +722,7 @@ overflow:
// 19. AnswerPartitionTable
// 19. AnswerPartitionTable
func
(
p
*
AnswerPartitionTable
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerPartitionTable
)
NEOEncodedLen
()
int
{
var
size
int
size
+=
12
size
+=
12
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
a
:=
&
p
.
RowList
[
i
]
...
@@ -810,6 +812,7 @@ overflow:
...
@@ -810,6 +812,7 @@ overflow:
// 20. NotifyPartitionTable
// 20. NotifyPartitionTable
func
(
p
*
NotifyPartitionTable
)
NEOEncodedLen
()
int
{
func
(
p
*
NotifyPartitionTable
)
NEOEncodedLen
()
int
{
var
size
int
size
+=
12
size
+=
12
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
a
:=
&
p
.
RowList
[
i
]
...
@@ -1092,8 +1095,7 @@ overflow:
...
@@ -1092,8 +1095,7 @@ overflow:
// 27. AnswerLockedTransactions
// 27. AnswerLockedTransactions
func
(
p
*
AnswerLockedTransactions
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerLockedTransactions
)
NEOEncodedLen
()
int
{
size
+=
4
+
len
(
p
.
TidDict
)
*
16
return
4
+
len
(
p
.
TidDict
)
*
16
return
0
}
}
func
(
p
*
AnswerLockedTransactions
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerLockedTransactions
)
NEOEncode
(
data
[]
byte
)
{
...
@@ -2594,6 +2596,7 @@ overflow:
...
@@ -2594,6 +2596,7 @@ overflow:
// 58. AnswerPartitionList
// 58. AnswerPartitionList
func
(
p
*
AnswerPartitionList
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerPartitionList
)
NEOEncodedLen
()
int
{
var
size
int
size
+=
12
size
+=
12
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
a
:=
&
p
.
RowList
[
i
]
...
@@ -2706,6 +2709,7 @@ overflow:
...
@@ -2706,6 +2709,7 @@ overflow:
// 60. AnswerNodeList
// 60. AnswerNodeList
func
(
p
*
AnswerNodeList
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerNodeList
)
NEOEncodedLen
()
int
{
var
size
int
size
+=
4
size
+=
4
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
...
@@ -2917,6 +2921,7 @@ overflow:
...
@@ -2917,6 +2921,7 @@ overflow:
// 64. NotifyNodeInformation
// 64. NotifyNodeInformation
func
(
p
*
NotifyNodeInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
NotifyNodeInformation
)
NEOEncodedLen
()
int
{
var
size
int
size
+=
4
size
+=
4
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
...
@@ -3156,8 +3161,7 @@ overflow:
...
@@ -3156,8 +3161,7 @@ overflow:
// 70. AnswerObjectUndoSerial
// 70. AnswerObjectUndoSerial
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncodedLen
()
int
{
size
+=
4
+
len
(
p
.
ObjectTIDDict
)
*
25
return
4
+
len
(
p
.
ObjectTIDDict
)
*
25
return
0
}
}
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncode
(
data
[]
byte
)
{
...
@@ -3400,8 +3404,7 @@ overflow:
...
@@ -3400,8 +3404,7 @@ overflow:
// 77. CheckReplicas
// 77. CheckReplicas
func
(
p
*
CheckReplicas
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckReplicas
)
NEOEncodedLen
()
int
{
size
+=
4
+
len
(
p
.
PartitionDict
)
*
8
return
20
+
len
(
p
.
PartitionDict
)
*
8
return
16
}
}
func
(
p
*
CheckReplicas
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
CheckReplicas
)
NEOEncode
(
data
[]
byte
)
{
...
...
t/neo/protogen.go
View file @
7429c8ba
...
@@ -232,6 +232,9 @@ type sizer struct {
...
@@ -232,6 +232,9 @@ type sizer struct {
n
int
n
int
symLenv
[]
string
// symbolic lengths to add to size
symLenv
[]
string
// symbolic lengths to add to size
varSizeUsed
bool
// whether var size was used
varSizeUsed
bool
// whether var size was used
recvName
string
// receiver/type for top-level func
typeName
string
// or empty
}
}
type
encoder
struct
{
type
encoder
struct
{
...
@@ -249,7 +252,26 @@ var _ CodecCodeGen = (*encoder)(nil)
...
@@ -249,7 +252,26 @@ var _ CodecCodeGen = (*encoder)(nil)
var
_
CodecCodeGen
=
(
*
decoder
)(
nil
)
var
_
CodecCodeGen
=
(
*
decoder
)(
nil
)
func
(
s
*
sizer
)
generatedCode
()
string
{
func
(
s
*
sizer
)
generatedCode
()
string
{
return
s
.
String
()
// XXX -> d.buf.String() ?
prologue
:=
Buffer
{}
if
s
.
recvName
!=
""
{
prologue
.
emit
(
"func (%s *%s) NEOEncodedLen() int {"
,
s
.
recvName
,
s
.
typeName
)
}
if
s
.
varSizeUsed
{
prologue
.
emit
(
"var size int"
)
}
epilogue
:=
Buffer
{}
size
:=
fmt
.
Sprintf
(
"%v"
,
s
.
n
)
if
len
(
s
.
symLenv
)
>
0
{
size
+=
" + "
+
strings
.
Join
(
s
.
symLenv
,
" + "
)
}
if
s
.
varSizeUsed
{
size
+=
" + size"
}
epilogue
.
emit
(
"return %v"
,
size
)
epilogue
.
emit
(
"}
\n
"
)
return
prologue
.
String
()
+
s
.
String
()
+
epilogue
.
String
()
// XXX -> d.buf.String() ?
}
}
func
(
e
*
encoder
)
generatedCode
()
string
{
func
(
e
*
encoder
)
generatedCode
()
string
{
...
@@ -261,10 +283,9 @@ func (d *decoder) generatedCode() string {
...
@@ -261,10 +283,9 @@ func (d *decoder) generatedCode() string {
}
}
func
(
s
*
sizer
)
genPrologue
(
recvName
,
typeName
string
)
{
func
(
s
*
sizer
)
genPrologue
(
recvName
,
typeName
string
)
{
s
.
emit
(
"func (%s *%s) NEOEncodedLen() int {"
,
recvName
,
typeName
)
s
.
recvName
=
recvName
if
s
.
varSizeUsed
{
s
.
typeName
=
typeName
s
.
emit
(
"var size int"
)
//s.emit("func (%s *%s) NEOEncodedLen() int {", recvName, typeName)
}
}
}
func
(
e
*
encoder
)
genPrologue
(
recvName
,
typeName
string
)
{
func
(
e
*
encoder
)
genPrologue
(
recvName
,
typeName
string
)
{
...
@@ -277,6 +298,7 @@ func (d *decoder) genPrologue(recvName, typeName string) {
...
@@ -277,6 +298,7 @@ func (d *decoder) genPrologue(recvName, typeName string) {
}
}
func
(
s
*
sizer
)
genEpilogue
()
{
func
(
s
*
sizer
)
genEpilogue
()
{
/*
size := fmt.Sprintf("%v", s.n)
size := fmt.Sprintf("%v", s.n)
if len(s.symLenv) > 0 {
if len(s.symLenv) > 0 {
size += " + " + strings.Join(s.symLenv, " + ")
size += " + " + strings.Join(s.symLenv, " + ")
...
@@ -286,6 +308,7 @@ func (s *sizer) genEpilogue() {
...
@@ -286,6 +308,7 @@ func (s *sizer) genEpilogue() {
}
}
s.emit("return %v", size)
s.emit("return %v", size)
s.emit("}\n")
s.emit("}\n")
*/
}
}
func
(
e
*
encoder
)
genEpilogue
()
{
func
(
e
*
encoder
)
genEpilogue
()
{
...
@@ -442,10 +465,12 @@ func (s *sizer) genMap(path string, typ *types.Map, obj types.Object) {
...
@@ -442,10 +465,12 @@ func (s *sizer) genMap(path string, typ *types.Map, obj types.Object) {
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
if
keyFixed
&&
elemFixed
{
if
keyFixed
&&
elemFixed
{
s
.
emit
(
"size += 4 + len(%v) * %v"
,
path
,
keySize
+
elemSize
)
s
.
n
+=
4
s
.
symLenv
=
append
(
s
.
symLenv
,
fmt
.
Sprintf
(
"len(%v) * %v"
,
path
,
keySize
+
elemSize
))
return
return
}
}
s
.
varSizeUsed
=
true
s
.
emit
(
"size += %v + 4"
,
s
.
n
)
s
.
emit
(
"size += %v + 4"
,
s
.
n
)
s
.
n
=
0
s
.
n
=
0
s
.
emit
(
"for key := range %s {"
,
path
)
s
.
emit
(
"for key := range %s {"
,
path
)
...
...
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