Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. final Result<Record> fetch = sourceDbContext.select()
  2.         .from(table(properties.getTable()))
  3.         .where(field(UPDATED_AT).eq(currentOffset)
  4.           .and(field(ID).greaterThan(currentOffsetId))
  5.           .and(field(UPDATED_AT).lessThan(offsetNow.minusSeconds(fetchDelayInSeconds))))
  6.         .orderBy(field(UPDATED_AT), field(ID))
  7.         .limit(batchSize)
  8.         .fetch();
  9.  
  10.       if (fetch.size() < batchSize) {
  11.         final Result<Record> fetchGtUpdatedAt = sourceDbContext.select()
  12.           .from(table(properties.getTable()))
  13.           .where(field(UPDATED_AT).greaterThan(currentOffset)
  14.             .and(field(UPDATED_AT).lessThan(offsetNow.minusSeconds(fetchDelayInSeconds))))
  15.           .orderBy(field(UPDATED_AT), field(ID))
  16.           .limit(batchSize - fetch.size())
  17.           .fetch();
  18.         fetch.addAll(fetchGtUpdatedAt);
  19.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement