Skip to content

Commit 8754972

Browse files
committed
feat: set max node id func, to update L1 chunk max seg ID
1 parent 02d7ac9 commit 8754972

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

pychunkedgraph/graph/client/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def create_node_ids(self, chunk_id):
122122
def create_node_id(self, chunk_id):
123123
"""Generate a unique ID in the chunk."""
124124

125+
@abstractmethod
126+
def set_max_node_id(self, chunk_id, node_id):
127+
"""Gets the current maximum node ID in the chunk."""
128+
125129
@abstractmethod
126130
def get_max_node_id(self, chunk_id):
127131
"""Gets the current maximum node ID in the chunk."""

pychunkedgraph/graph/client/bigtable/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,19 @@ def create_node_id(
588588
"""Generate a unique node ID in the chunk."""
589589
return self.create_node_ids(chunk_id, 1, root_chunk=root_chunk)[0]
590590

591+
592+
def set_max_node_id(
593+
self, chunk_id: np.uint64, node_id: np.uint64
594+
) -> basetypes.NODE_ID:
595+
"""Set max segment ID for a given chunk."""
596+
size = int(np.uint64(chunk_id) ^ np.uint64(node_id))
597+
key = serialize_uint64(chunk_id, counter=True)
598+
column = attributes.Concurrency.Counter
599+
row = self._table.append_row(key)
600+
row.increment_cell_value(column.family_id, column.key, size)
601+
row = row.commit()
602+
603+
591604
def get_max_node_id(
592605
self, chunk_id: basetypes.CHUNK_ID, root_chunk=False
593606
) -> basetypes.NODE_ID:

pychunkedgraph/ingest/create/atomic_layer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def add_atomic_edges(
3535
return
3636

3737
chunk_ids = cg.get_chunk_ids_from_node_ids(chunk_node_ids)
38-
assert len(np.unique(chunk_ids)) == 1
38+
assert len(np.unique(chunk_ids)) == 1, np.unique(chunk_ids)
39+
40+
max_node_id = np.max(chunk_node_ids)
41+
cg.id_client.set_max_node_id(chunk_ids[0], max_node_id)
3942

4043
graph, _, _, unique_ids = build_gt_graph(chunk_edge_ids, make_directed=True)
4144
ccs = connected_components(graph)

pychunkedgraph/repair/fake_edges.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from os import environ
1010
from typing import Optional
1111

12-
environ["BIGTABLE_PROJECT"] = "<>"
13-
environ["BIGTABLE_INSTANCE"] = "<>"
14-
environ["GOOGLE_APPLICATION_CREDENTIALS"] = "<path>"
12+
# environ["BIGTABLE_PROJECT"] = "<>"
13+
# environ["BIGTABLE_INSTANCE"] = "<>"
14+
# environ["GOOGLE_APPLICATION_CREDENTIALS"] = "<path>"
1515

1616
from pychunkedgraph.graph import edits
1717
from pychunkedgraph.graph import ChunkedGraph

pychunkedgraph/tests/test_uncategorized.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_build_single_node(self, gen_graph):
139139
assert len(children) == 1 and children[0] == to_label(cg, 1, 0, 0, 0, 0)
140140
# Make sure there are not any more entries in the table
141141
# include counters, meta and version rows
142-
assert len(res.rows) == 1 + 1 + 1 + 1 + 1
142+
assert len(res.rows) == 1 + 1 + 1 + 1 + 1 + 1
143143

144144
@pytest.mark.timeout(30)
145145
def test_build_single_edge(self, gen_graph):
@@ -192,7 +192,7 @@ def test_build_single_edge(self, gen_graph):
192192

193193
# Make sure there are not any more entries in the table
194194
# include counters, meta and version rows
195-
assert len(res.rows) == 2 + 1 + 1 + 1 + 1
195+
assert len(res.rows) == 2 + 1 + 1 + 1 + 1 + 1
196196

197197
@pytest.mark.timeout(30)
198198
def test_build_single_across_edge(self, gen_graph):
@@ -294,7 +294,7 @@ def test_build_single_across_edge(self, gen_graph):
294294

295295
# Make sure there are not any more entries in the table
296296
# include counters, meta and version rows
297-
assert len(res.rows) == 2 + 2 + 1 + 3 + 1 + 1
297+
assert len(res.rows) == 2 + 2 + 1 + 3 + 1 + 1 + 2
298298

299299
@pytest.mark.timeout(30)
300300
def test_build_single_edge_and_single_across_edge(self, gen_graph):
@@ -402,7 +402,7 @@ def test_build_single_edge_and_single_across_edge(self, gen_graph):
402402

403403
# Make sure there are not any more entries in the table
404404
# include counters, meta and version rows
405-
assert len(res.rows) == 3 + 2 + 1 + 3 + 1 + 1
405+
assert len(res.rows) == 3 + 2 + 1 + 3 + 1 + 1 + 2
406406

407407
@pytest.mark.timeout(120)
408408
def test_build_big_graph(self, gen_graph):

0 commit comments

Comments
 (0)