11package dev .dbos .transact .database .dao ;
22
3+ import static java .util .stream .Collectors .joining ;
4+
35import dev .dbos .transact .Constants ;
46import dev .dbos .transact .database .DbContext ;
57import dev .dbos .transact .database .GetEventCaller ;
3234import java .util .Set ;
3335import java .util .UUID ;
3436
35- import static java .util .stream .Collectors .joining ;
36-
3737import org .jspecify .annotations .NonNull ;
3838import org .jspecify .annotations .Nullable ;
3939import org .slf4j .Logger ;
@@ -57,7 +57,8 @@ private static Map<String, Set<String>> findForkDescendantsTxn(
5757 """
5858 SELECT workflow_uuid, forked_from FROM "%s".workflow_status
5959 WHERE forked_from IN (%s)
60- """ .formatted (schema , placeholders );
60+ """
61+ .formatted (schema , placeholders );
6162 try (var stmt = conn .prepareStatement (sql )) {
6263 for (int i = 0 ; i < frontier .size (); i ++) stmt .setString (i + 1 , frontier .get (i ));
6364 List <String > next = new ArrayList <>();
@@ -104,11 +105,7 @@ public static void sendBulk(
104105 }
105106
106107 // Reject duplicate idempotency keys within the batch
107- var keys =
108- messages .stream ()
109- .map (SendMessage ::idempotencyKey )
110- .filter (Objects ::nonNull )
111- .toList ();
108+ var keys = messages .stream ().map (SendMessage ::idempotencyKey ).filter (Objects ::nonNull ).toList ();
112109 if (keys .size () != keys .stream ().distinct ().count ()) {
113110 throw new IllegalArgumentException ("Duplicate idempotency keys within sendBulk batch" );
114111 }
@@ -120,7 +117,9 @@ public static void sendBulk(
120117 record SerializedPair (SendMessage msg , SerializationUtil .SerializedResult serialized ) {}
121118 List <SerializedPair > pairs = new ArrayList <>(messages .size ());
122119 for (var msg : messages ) {
123- pairs .add (new SerializedPair (msg , SerializationUtil .serializeValue (msg .message (), serialization , serializer )));
120+ pairs .add (
121+ new SerializedPair (
122+ msg , SerializationUtil .serializeValue (msg .message (), serialization , serializer )));
124123 }
125124
126125 try (Connection conn = ctx .getConnection ()) {
@@ -140,12 +139,17 @@ record SerializedPair(SendMessage msg, SerializationUtil.SerializedResult serial
140139 // Collect all destination IDs for fork resolution
141140 Map <String , Set <String >> forkDescendants = Map .of ();
142141 if (sendToForks ) {
143- List <String > destIds = pairs .stream ().map (p -> p .msg ().destinationId ()).distinct ().toList ();
142+ List <String > destIds =
143+ pairs .stream ().map (p -> p .msg ().destinationId ()).distinct ().toList ();
144144 forkDescendants = findForkDescendantsTxn (conn , ctx .schema (), destIds );
145145 }
146146
147147 // Build insert rows: base dest + sorted descendants
148- record InsertRow (String destId , SerializationUtil .SerializedResult serialized , String topic , String messageUuid ) {}
148+ record InsertRow (
149+ String destId ,
150+ SerializationUtil .SerializedResult serialized ,
151+ String topic ,
152+ String messageUuid ) {}
149153 List <InsertRow > rows = new ArrayList <>();
150154 for (var pair : pairs ) {
151155 var msg = pair .msg ();
@@ -177,7 +181,8 @@ record InsertRow(String destId, SerializationUtil.SerializedResult serialized, S
177181 (destination_uuid, topic, message, serialization, message_uuid)
178182 VALUES (?, ?, ?, ?, ?)
179183 ON CONFLICT (message_uuid) DO NOTHING
180- """ .formatted (ctx .schema ());
184+ """
185+ .formatted (ctx .schema ());
181186
182187 try (PreparedStatement stmt = conn .prepareStatement (sql )) {
183188 for (var row : rows ) {
@@ -200,7 +205,8 @@ ON CONFLICT (message_uuid) DO NOTHING
200205
201206 if (workflowId != null ) {
202207 var output = new StepResult (workflowId , stepId , functionName , null , null , null , null );
203- StepsDAO .recordStepResult (conn , ctx .schema (), output , startTime , System .currentTimeMillis ());
208+ StepsDAO .recordStepResult (
209+ conn , ctx .schema (), output , startTime , System .currentTimeMillis ());
204210 }
205211
206212 conn .commit ();
0 commit comments