@@ -101,7 +101,13 @@ def _get_remapping(chunk_edges_d: dict):
101101
102102
103103def _process_component (
104- cg , chunk_edges_d , parent_id , node_ids , sparse_indices , remapping , time_stamp ,
104+ cg ,
105+ chunk_edges_d ,
106+ parent_id ,
107+ node_ids ,
108+ sparse_indices ,
109+ remapping ,
110+ time_stamp ,
105111):
106112 nodes = []
107113 chunk_out_edges = [] # out = between + cross
@@ -145,3 +151,49 @@ def _get_outgoing_edges(node_id, chunk_edges_d, sparse_indices, remapping):
145151 # edges that this node is part of
146152 chunk_out_edges = np .concatenate ([chunk_out_edges , edges [row_ids ]])
147153 return chunk_out_edges
154+
155+
156+ def postprocess_atomic_chunk (
157+ cg : ChunkedGraph ,
158+ chunk_coord : np .ndarray ,
159+ time_stamp : Optional [datetime .datetime ] = None ,
160+ ):
161+ time_stamp = get_valid_timestamp (time_stamp )
162+
163+ chunk_id = cg .get_chunk_id (
164+ layer = 2 , x = chunk_coord [0 ], y = chunk_coord [1 ], z = chunk_coord [2 ]
165+ )
166+
167+ properties = [
168+ attributes .Connectivity .CrossChunkEdge [l ] for l in range (2 , cg .meta .layer_count )
169+ ]
170+
171+ chunk_rr = cg .range_read_chunk (
172+ chunk_id , properties = properties , time_stamp = time_stamp
173+ )
174+
175+ result = {}
176+ for l2id , raw_cx_edges in chunk_rr .items ():
177+ try :
178+ cx_edges = {
179+ prop .index : val [0 ].value .copy () for prop , val in raw_cx_edges .items ()
180+ }
181+ result [l2id ] = cx_edges
182+ except KeyError :
183+ continue
184+
185+ nodes = []
186+ val_dicts = []
187+ for l2id , cx_edges in result .items ():
188+ val_dict = {}
189+ for layer , edges in cx_edges .items ():
190+ l2_edges = np .zeros_like (edges )
191+ l2_edges [:, 0 ] = l2id
192+ l2_edges [:, 1 ] = cg .get_parents (edges [:, 1 ])
193+ col = attributes .Connectivity .L2CrossChunkEdge [layer ]
194+ val_dict [col ] = np .unique (l2_edges , axis = 0 )
195+ val_dicts .append (val_dict )
196+
197+ r_key = serializers .serialize_uint64 (l2id )
198+ nodes .append (cg .client .mutate_row (r_key , val_dict , time_stamp = time_stamp ))
199+ cg .client .write (nodes )
0 commit comments