Search in sources :

Example 1 with JdbcFieldInfo

use of org.apache.arrow.adapter.jdbc.JdbcFieldInfo in project Mycat2 by MyCATApache.

the class NewVertxConnectionImpl method resultSetColumnToVectorRowSchema.

public static Schema resultSetColumnToVectorRowSchema(List<ColumnDefinition> columnDefinitions) {
    int columnCount = columnDefinitions.size();
    ImmutableList.Builder<Field> builder = ImmutableList.builder();
    JdbcToArrowConfigBuilder jdbcToArrowConfigBuilder = new JdbcToArrowConfigBuilder();
    JdbcToArrowConfig jdbcToArrowConfig = jdbcToArrowConfigBuilder.build();
    for (int i = 0; i < columnCount; i++) {
        ColumnDefinition columnDefinition = columnDefinitions.get(i);
        String columnName = columnDefinition.name();
        int columnType = columnDefinition.jdbcType().getVendorTypeNumber();
        boolean signed = (columnDefinition.flags() & MySQLFieldsType.UNSIGNED_FLAG) == 0;
        boolean nullable = (columnDefinition.flags() & MySQLFieldsType.UNSIGNED_FLAG) == 0;
        ArrowType arrowType = (ArrowType) jdbcToArrowConfig.getJdbcToArrowTypeConverter().apply(new JdbcFieldInfo(columnType, 0, 0));
        FieldType fieldType = new FieldType(nullable, arrowType, null);
        builder.add(new org.apache.arrow.vector.types.pojo.Field(columnName, fieldType, Collections.emptyList()));
    }
    return new org.apache.arrow.vector.types.pojo.Schema(builder.build());
}
Also used : JdbcToArrowConfigBuilder(org.apache.arrow.adapter.jdbc.JdbcToArrowConfigBuilder) JdbcFieldInfo(org.apache.arrow.adapter.jdbc.JdbcFieldInfo) ImmutableList(com.google.common.collect.ImmutableList) Schema(org.apache.arrow.vector.types.pojo.Schema) ArrowType(org.apache.arrow.vector.types.pojo.ArrowType) Field(org.apache.arrow.vector.types.pojo.Field) ColumnDefinition(io.vertx.mysqlclient.impl.protocol.ColumnDefinition) FieldType(org.apache.arrow.vector.types.pojo.FieldType) Field(org.apache.arrow.vector.types.pojo.Field) org.apache.arrow.vector(org.apache.arrow.vector) JdbcToArrowConfig(org.apache.arrow.adapter.jdbc.JdbcToArrowConfig)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ColumnDefinition (io.vertx.mysqlclient.impl.protocol.ColumnDefinition)1 JdbcFieldInfo (org.apache.arrow.adapter.jdbc.JdbcFieldInfo)1 JdbcToArrowConfig (org.apache.arrow.adapter.jdbc.JdbcToArrowConfig)1 JdbcToArrowConfigBuilder (org.apache.arrow.adapter.jdbc.JdbcToArrowConfigBuilder)1 org.apache.arrow.vector (org.apache.arrow.vector)1 ArrowType (org.apache.arrow.vector.types.pojo.ArrowType)1 Field (org.apache.arrow.vector.types.pojo.Field)1 FieldType (org.apache.arrow.vector.types.pojo.FieldType)1 Schema (org.apache.arrow.vector.types.pojo.Schema)1