use of com.mysql.cj.result.Field in project Mycat2 by MyCATApache.
the class NewMycatConnectionImpl method getJdbcRowMetaData.
@NotNull
private MycatRowMetaData getJdbcRowMetaData(ResultSetMetaData jdbcMetaData) throws SQLException {
MycatRowMetaData mycatRowMetaData;
if (isMySQLDriver || "com.mysql.cj.jdbc.result.ResultSetMetaData".equals(jdbcMetaData.getClass().getCanonicalName())) {
isMySQLDriver = true;
com.mysql.cj.jdbc.result.ResultSetMetaData mysqlJdbcMetaData = (com.mysql.cj.jdbc.result.ResultSetMetaData) jdbcMetaData;
int columnCount = mysqlJdbcMetaData.getColumnCount();
Field[] fields = mysqlJdbcMetaData.getFields();
List<ColumnDefPacket> columnDefPackets = new ArrayList<>(columnCount);
for (int i = 0; i < columnCount; i++) {
ColumnDefPacketImpl columnDefPacket = new ColumnDefPacketImpl();
Field field = fields[i];
columnDefPacket.setColumnSchema(ColumnDefPacketImpl.getBytes(field.getDatabaseName()));
columnDefPacket.setColumnTable(ColumnDefPacketImpl.getBytes(field.getTableName()));
columnDefPacket.setColumnOrgTable(ColumnDefPacketImpl.getBytes(field.getOriginalTableName()));
columnDefPacket.setColumnName(ColumnDefPacketImpl.getBytes(field.getName()));
columnDefPacket.setColumnOrgName(ColumnDefPacketImpl.getBytes(field.getOriginalName()));
columnDefPacket.setColumnCharsetSet((field.getCollationIndex()));
columnDefPacket.setColumnLength((int) field.getLength());
columnDefPacket.setColumnType((int) field.getMysqlTypeId());
columnDefPacket.setColumnFlags((int) field.getFlags());
columnDefPacket.setColumnDecimals((byte) field.getDecimals());
columnDefPackets.add(columnDefPacket);
}
mycatRowMetaData = new MycatMySQLRowMetaData(columnDefPackets);
} else {
mycatRowMetaData = new CopyMycatRowMetaData(new JdbcRowMetaData(jdbcMetaData));
}
return mycatRowMetaData;
}
use of com.mysql.cj.result.Field in project Mycat2 by MyCATApache.
the class NewMycatConnectionImpl method getFieldVectors.
@NotNull
private FieldVector[] getFieldVectors(MycatField[] mycatFields, BufferAllocator allocator) {
FieldVector[] fieldVectors = new FieldVector[mycatFields.length];
int i = 0;
for (MycatField mycatField : mycatFields) {
String name = mycatField.getName();
boolean nullable = mycatField.isNullable();
ArrowType arrowType = mycatField.getMycatDataType().getArrowType();
FieldType fieldType = new FieldType(nullable, arrowType, null);
org.apache.arrow.vector.types.pojo.Field field = new org.apache.arrow.vector.types.pojo.Field(name, fieldType, Collections.emptyList());
FieldVector fieldVector = mycatField.getMycatDataType().createFieldVector(field, allocator);
fieldVectors[i] = fieldVector;
i++;
}
return fieldVectors;
}
Aggregations