Java Code Examples for io.vertx.sqlclient.Row#addValue()

The following examples show how to use io.vertx.sqlclient.Row#addValue() . 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: RowResultDecoder.java    From vertx-sql-client with Apache License 2.0 6 votes vote down vote up
@Override
protected Row decodeRow(int len, ByteBuf in) {
  Row row = new RowImpl(desc);
  for (int c = 0; c < len; ++c) {
    int length = in.readInt();
    Object decoded = null;
    if (length != -1) {
      PgColumnDesc columnDesc = desc.columns[c];
      if (columnDesc.dataFormat == DataFormat.BINARY) {
        decoded = DataTypeCodec.decodeBinary(columnDesc.dataType, in.readerIndex(), length, in);
      } else {
        decoded = DataTypeCodec.decodeText(columnDesc.dataType, in.readerIndex(), length, in);
      }
      in.skipBytes(length);
    }
    row.addValue(decoded);
  }
  return row;
}
 
Example 2
Source File: RowResultDecoder.java    From vertx-sql-client with Apache License 2.0 6 votes vote down vote up
@Override
protected Row decodeRow(int len, ByteBuf in) {
  Row row = new DB2RowImpl(rowDesc);
  for (int i = 1; i < rowDesc.columnDefinitions().columns_ + 1; i++) {
    int startingIdx = cursor.dataBuffer_.readerIndex();
    Object o = cursor.getObject(i);
    int endingIdx = cursor.dataBuffer_.readerIndex();
    // TODO: Remove this once all getObject paths are implemented safely
    // or add unit tests for this in the DRDA project
    if (startingIdx != endingIdx) {
      System.out.println("WARN: Reader index changed while getting data. Changed from " + startingIdx + " to "
          + endingIdx + " while obtaining object " + o);
    }
    if (o instanceof BigDecimal) {
      o = Numeric.create((BigDecimal) o);
    }
    row.addValue(o);
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("decoded row values: " + row.deepToString());
  }
  return row;
}
 
Example 3
Source File: RowResultDecoder.java    From vertx-sql-client with Apache License 2.0 6 votes vote down vote up
private Row decodeMssqlNbcRow(int len, ByteBuf in) {
  Row row = new MSSQLRowImpl(desc);
  int nullBitmapByteCount = (len >> 3) + 1;
  int nullBitMapStartIdx = in.readerIndex();
  in.skipBytes(nullBitmapByteCount);

  for (int c = 0; c < len; c++) {
    int bytePos = c >> 3;
    int bitPos = c & 7;
    byte mask = (byte) (1 << bitPos);
    byte nullByte = in.getByte(nullBitMapStartIdx + bytePos);
    Object decoded = null;
    if ((nullByte & mask) == 0) {
      // not null
      ColumnData columnData = desc.columnDatas[c];
      decoded = MSSQLDataTypeCodec.decode(columnData.dataType(), in);
    }
    row.addValue(decoded);
  }
  return row;
}
 
Example 4
Source File: PostgresClientTest.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
private RowSet<Row> getMockTestJsonbPojoResultSet(int total) {
  List<String> columnNames = new ArrayList<String>(Arrays.asList(new String[] {
    "jsonb"
  }));
  RowDesc rowDesc = new RowDesc(columnNames);
  List<String> baz = new ArrayList<String>(Arrays.asList(new String[] {
      "This", "is", "a", "test"
  }));
  List<Row> rows = new LinkedList<>();
  for (int i = 0; i < total; i++) {
    Row row = new RowImpl(rowDesc);
    row.addValue(new JsonObject()
        .put("id", UUID.randomUUID().toString())
        .put("foo", "foo " + i)
        .put("bar", "bar " + i)
        .put("biz", (double) i)
        .put("baz", baz)
    );
    rows.add(row);
  }
  return new LocalRowSet(total).withColumns(columnNames).withRows(rows);
}
 
Example 5
Source File: RowResultDecoder.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
private Row decodeMssqlRow(int len, ByteBuf in) {
  Row row = new MSSQLRowImpl(desc);
  for (int c = 0; c < len; c++) {
    Object decoded = null;
    ColumnData columnData = desc.columnDatas[c];
    decoded = MSSQLDataTypeCodec.decode(columnData.dataType(), in);
    row.addValue(decoded);
  }
  return row;
}