2727import  storm .trident .state .map .OpaqueMap ;
2828import  storm .trident .state .map .TransactionalMap ;
2929import  backtype .storm .task .IMetricsContext ;
30+ import  backtype .storm .topology .FailedException ;
3031
3132import  com .google .common .base .Function ;
3233import  com .google .common .base .Joiner ;
@@ -136,7 +137,7 @@ public void multiPut(final List<List<Object>> keys, final List<T> values) {
136137          .append (buildColumns ())
137138          .append (") AS (" )
138139            .append ("VALUES " )
139-             .append (Joiner .on (", " ).join (repeat ("("  + Joiner . on ( "," ). join ( repeat ( "?" ,  paramCount ) ) + ")" , pkeys .size ())))
140+             .append (Joiner .on (", " ).join (repeat ("("  + buildValueParams ( ) + ")" , pkeys .size ())))
140141          .append (")," )
141142          .append ("updated AS (" )
142143            .append ("UPDATE " ).append (config .getTable ()).append (" t " )
@@ -198,6 +199,7 @@ public String apply(final String col) {
198199        ps .execute ();
199200      } catch  (final  SQLException  ex ) {
200201        logger .error ("Multiput update failed" , ex );
202+         throw  new  FailedException (ex );
201203      } finally  {
202204        if  (ps  != null ) {
203205          try  {
@@ -217,6 +219,16 @@ private String buildColumns() {
217219    return  Joiner .on ("," ).join (cols );
218220  }
219221
222+   private  String  buildValueParams () {
223+     final  List <String > types  = Lists .newArrayList (config .getKeyTypes ()); // the columns for the composite unique key 
224+     types .addAll (getValueTypes ());
225+     List <String > withCast  = new  ArrayList <>();
226+     for (String  type  : types ) {
227+       withCast .add (String .format ("?::%s" , type ));
228+     }
229+     return  Joiner .on ("," ).join (withCast );
230+   }
231+ 
220232  private  String  buildKeyQuery (final  int  n ) {
221233    final  String  single  = "("  + Joiner .on (" AND " ).join (Lists .transform (Arrays .asList (config .getKeyColumns ()), new  Function <String , String >() {
222234      @ Override 
@@ -243,6 +255,17 @@ public String apply(final String field) {
243255    return  cols ;
244256  }
245257
258+   private  List <String > getValueTypes () {
259+     final  List <String > cols  = Lists .newArrayList (config .getValueTypes ()); // the columns storing the values 
260+     if  (StateType .OPAQUE .equals (config .getType ()) || StateType .TRANSACTIONAL .equals (config .getType ())) {
261+       cols .add ("bigint" );
262+     }
263+     if  (StateType .OPAQUE .equals (config .getType ())) {
264+       cols .addAll (Lists .newArrayList (config .getValueTypes ()));
265+     }
266+     return  cols ;
267+   }
268+ 
246269  /** 
247270   * run the multi get query, passing in the list of keys and returning key tuples mapped to value tuples 
248271   * 
0 commit comments