Java Code Examples for io.vertx.sqlclient.RowSet#iterator()

The following examples show how to use io.vertx.sqlclient.RowSet#iterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PgUtil.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
private static <T, C> C collection(Class<T> clazz, Class<C> collectionClazz, RowSet<Row> resultSet, int offset, int limit)
    throws ReflectiveOperationException, IOException {

  int totalRecords = 0;
  int resultSize = resultSet.size();
  List<T> recordList = new ArrayList<>(resultSize);
  RowIterator<Row> iterator = resultSet.iterator();
  while (iterator.hasNext()) {
    Row row = iterator.next();
    String jsonb = row.getValue(JSON_COLUMN).toString();
    recordList.add(OBJECT_MAPPER.readValue(jsonb, clazz));
    totalRecords = row.getInteger(PostgresClient.COUNT_FIELD);
  }
  totalRecords = PostgresClient.getTotalRecords(resultSize, totalRecords, offset, limit);
  return collection(collectionClazz, recordList, totalRecords);
}
 
Example 2
Source File: QueryVariationsTest.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
private int assertSequenceResult(TestContext ctx, RowSet<Row> rowSet, Consumer<Integer> validation) {
  ctx.assertEquals(1, rowSet.size());
  RowIterator<Row> rows = rowSet.iterator();
      ctx.assertTrue(rows.hasNext());
      Row row = rows.next();
      ctx.assertNotNull(row);
      int seqVal = row.getInteger(0);
      validation.accept(seqVal);
      return seqVal;
}
 
Example 3
Source File: OutStream.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
public OutStream(RowSet<Row> result) {
  JsonArray ar = new JsonArray();
  RowIterator<Row> it = result.iterator();
  while (it.hasNext()) {
    Row row = it.next();
    JsonObject o = new JsonObject();
    for (int i = 0; i < row.size(); i++) {
      o.put(row.getColumnName(i), row.getValue(i));
    }
    ar.add(o);
  }
  data = ar.encode();
}
 
Example 4
Source File: PostgresClientIT.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
private String intsAsString(RowSet<Row> resultSet) {
  StringBuilder s = new StringBuilder();
  RowIterator<Row> iterator = resultSet.iterator();
  while (iterator.hasNext()) {
    if (s.length() > 0) {
      s.append(", ");
    }
    s.append(iterator.next().getInteger(0));
  }
  return s.toString();
}
 
Example 5
Source File: SqlClientConnection.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
public RowSetResult(RowSet<Row> rowset) {
	this.rowset = rowset;
	it = rowset.iterator();
}
 
Example 6
Source File: ResultSetAdaptor.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ResultSetAdaptor(RowSet<Row> rows) {
	this.iterator = rows.iterator();
	this.rows = rows;
}