3737import java .sql .Connection ;
3838import java .sql .SQLException ;
3939import java .util .Collection ;
40+ import java .util .Objects ;
4041import java .util .Set ;
4142import java .util .concurrent .ConcurrentHashMap ;
4243
@@ -106,8 +107,8 @@ public static DbSequence getPreallocatingSequence(Container c, String name, int
106107 return _sequences .computeIfAbsent (key , (k ) -> new DbSequence .Preallocate (c , name , ensure (c , name , id ), batchSize ));
107108 }
108109
109- /* This is not a recommended, but if you get stuck and need to reserve a block at once */
110- public static long reserveSequentialBlock (DbSequence seq , int count )
110+ /* This is not recommended, but if you get stuck and need to reserve a block at once */
111+ public static long reserveSequentialBlock (DbSequence seq , long count )
111112 {
112113 if (!(seq instanceof DbSequence .Preallocate ))
113114 throw new IllegalStateException ();
@@ -123,10 +124,7 @@ private static int ensure(Container c, String name, int id, boolean withUpdateLo
123124 {
124125 Integer rowId = getRowId (c , name , id , withUpdateLock );
125126
126- if (null != rowId )
127- return rowId ;
128- else
129- return create (c , name , id , withUpdateLock );
127+ return Objects .requireNonNullElseGet (rowId , () -> create (c , name , id , withUpdateLock ));
130128 }
131129
132130 public static @ Nullable Integer getRowId (Container c , String name , int id )
@@ -284,7 +282,7 @@ static long next(DbSequence sequence)
284282 // .first value returned is 'current', call to next() should return current+1
285283 // .second value is reserved for use by caller
286284 // in other words, next() should return values [pair.first+1, pair.second] inclusive
287- static Pair <Long ,Long > reserve (DbSequence sequence , int count )
285+ static Pair <Long ,Long > reserve (DbSequence sequence , long count )
288286 {
289287 TableInfo tinfo = getTableInfo ();
290288
0 commit comments