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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
f0adc66c
Commit
f0adc66c
authored
Jul 31, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master: simplify pt.addNode() a little
parent
005cb829
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
25 deletions
+14
-25
neo/master/pt.py
neo/master/pt.py
+14
-25
No files found.
neo/master/pt.py
View file @
f0adc66c
...
@@ -173,16 +173,13 @@ class PartitionTable(neo.lib.pt.PartitionTable):
...
@@ -173,16 +173,13 @@ class PartitionTable(neo.lib.pt.PartitionTable):
cell_list
=
[]
cell_list
=
[]
node_count
=
self
.
count_dict
.
get
(
node
,
0
)
node_count
=
self
.
count_dict
.
get
(
node
,
0
)
for
offset
,
row
in
enumerate
(
self
.
partition_list
):
for
offset
,
row
in
enumerate
(
self
.
partition_list
):
feeding_cell
=
None
max_count
=
0
max_count
=
0
max_cell
=
None
max_cell
=
None
num_cells
=
0
num_cells
=
0
for
cell
in
row
:
for
cell
in
row
:
if
cell
.
getNode
()
is
node
:
if
cell
.
getNode
()
is
node
:
break
break
if
cell
.
isFeeding
():
if
not
cell
.
isFeeding
():
feeding_cell
=
cell
else
:
num_cells
+=
1
num_cells
+=
1
count
=
self
.
count_dict
[
cell
.
getNode
()]
count
=
self
.
count_dict
[
cell
.
getNode
()]
if
count
>
max_count
:
if
count
>
max_count
:
...
@@ -190,25 +187,17 @@ class PartitionTable(neo.lib.pt.PartitionTable):
...
@@ -190,25 +187,17 @@ class PartitionTable(neo.lib.pt.PartitionTable):
max_cell
=
cell
max_cell
=
cell
else
:
else
:
if
num_cells
<=
self
.
nr
:
if
self
.
nr
<
num_cells
:
row
.
append
(
Cell
(
node
,
CellStates
.
OUT_OF_DATE
))
if
node_count
+
1
>=
max_count
:
cell_list
.
append
((
offset
,
node
.
getUUID
(),
continue
CellStates
.
OUT_OF_DATE
))
if
max_cell
.
isReadable
():
node_count
+=
1
elif
node_count
+
1
<
max_count
:
if
feeding_cell
is
not
None
or
not
max_cell
.
isReadable
():
# If there is a feeding cell already or it is
# out-of-date, just drop the node.
row
.
remove
(
max_cell
)
cell_list
.
append
((
offset
,
max_cell
.
getUUID
(),
CellStates
.
DISCARDED
))
self
.
count_dict
[
max_cell
.
getNode
()]
-=
1
else
:
# Otherwise, use it as a feeding cell for safety.
max_cell
.
setState
(
CellStates
.
FEEDING
)
max_cell
.
setState
(
CellStates
.
FEEDING
)
cell_list
.
append
((
offset
,
max_cell
.
getUUID
(),
cell_list
.
append
((
offset
,
max_cell
.
getUUID
(),
CellStates
.
FEEDING
))
CellStates
.
FEEDING
))
# Don't count a feeding cell.
else
:
row
.
remove
(
max_cell
)
cell_list
.
append
((
offset
,
max_cell
.
getUUID
(),
CellStates
.
DISCARDED
))
self
.
count_dict
[
max_cell
.
getNode
()]
-=
1
self
.
count_dict
[
max_cell
.
getNode
()]
-=
1
row
.
append
(
Cell
(
node
,
CellStates
.
OUT_OF_DATE
))
row
.
append
(
Cell
(
node
,
CellStates
.
OUT_OF_DATE
))
cell_list
.
append
((
offset
,
node
.
getUUID
(),
cell_list
.
append
((
offset
,
node
.
getUUID
(),
...
...
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