Search in sources :

Example 11 with ColumnDefinition

use of io.vertx.mysqlclient.impl.protocol.ColumnDefinition in project Mycat2 by MyCATApache.

the class QueryCommandBaseCodec method handleResultsetColumnDefinitions.

protected void handleResultsetColumnDefinitions(ByteBuf payload) {
    ColumnDefinition def = decodeColumnDefinitionPacketPayload(payload);
    columnDefinitions[currentColumn++] = def;
    if (currentColumn == columnDefinitions.length) {
        // all column definitions have been decoded, switch to column definitions decoding completed state
        if (isDeprecatingEofFlagEnabled()) {
            // we enabled the DEPRECATED_EOF flag and don't need to accept an EOF_Packet
            handleResultsetColumnDefinitionsDecodingCompleted();
        } else {
            // we need to decode an EOF_Packet before handling rows, to be compatible with MySQL version below 5.7.5
            commandHandlerState = CommandHandlerState.COLUMN_DEFINITIONS_DECODING_COMPLETED;
        }
    }
}
Also used : ColumnDefinition(io.vertx.mysqlclient.impl.protocol.ColumnDefinition)

Example 12 with ColumnDefinition

use of io.vertx.mysqlclient.impl.protocol.ColumnDefinition in project Mycat2 by MyCATApache.

the class BaseRowObservable method toColumnMetaData.

public static MycatRowMetaData toColumnMetaData(List<ColumnDescriptor> event) {
    ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
    for (ColumnDescriptor columnDescriptor : event) {
        if (columnDescriptor instanceof ColumnDefinition) {
            ColumnDefinition columnDefinition = (ColumnDefinition) columnDescriptor;
            String schemaName = columnDefinition.schema();
            String tableName = columnDefinition.orgTable();
            String columnName = columnDefinition.name();
            int columnType = columnDefinition.type().jdbcType.getVendorTypeNumber();
            int precision = 0;
            int scale = 0;
            String columnLabel = columnDefinition.name();
            boolean isAutoIncrement = false;
            boolean isCaseSensitive = false;
            boolean isNullable = (columnDefinition.flags() & ColumnDefinition.ColumnDefinitionFlags.NOT_NULL_FLAG) == 0;
            boolean isSigned = true;
            int displaySize = (int) columnDefinition.columnLength();
            resultSetBuilder.addColumnInfo(schemaName, tableName, columnName, columnType, precision, scale, columnLabel, isAutoIncrement, isCaseSensitive, isNullable, isSigned, displaySize);
        } else {
            resultSetBuilder.addColumnInfo(columnDescriptor.name(), columnDescriptor.jdbcType());
        }
    }
    RowBaseIterator build = resultSetBuilder.build();
    return build.getMetaData();
}
Also used : ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) ColumnDescriptor(io.vertx.sqlclient.desc.ColumnDescriptor) ByteString(org.apache.calcite.avatica.util.ByteString) RowBaseIterator(io.mycat.api.collector.RowBaseIterator) ColumnDefinition(io.vertx.mysqlclient.impl.protocol.ColumnDefinition)

Example 13 with ColumnDefinition

use of io.vertx.mysqlclient.impl.protocol.ColumnDefinition in project vertx-sql-client by eclipse-vertx.

the class MySQLRowImpl method getLocalTime.

@Override
public LocalTime getLocalTime(int pos) {
    ColumnDefinition columnDefinition = rowDesc.columnDefinitions()[pos];
    Object val = getValue(pos);
    if (columnDefinition.type() == DataType.TIME && val instanceof Duration) {
        // map MySQL TIME data type to java.time.LocalTime
        Duration duration = (Duration) val;
        return LocalTime.ofNanoOfDay(duration.toNanos());
    } else {
        return super.getLocalTime(pos);
    }
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Duration(java.time.Duration) ColumnDefinition(io.vertx.mysqlclient.impl.protocol.ColumnDefinition)

Aggregations

ColumnDefinition (io.vertx.mysqlclient.impl.protocol.ColumnDefinition)13 DataType (io.vertx.mysqlclient.impl.datatype.DataType)7 ColumnDefPacketImpl (io.mycat.beans.mysql.packet.ColumnDefPacketImpl)4 ImmutableList (com.google.common.collect.ImmutableList)3 RowBaseIterator (io.mycat.api.collector.RowBaseIterator)3 ResultSetBuilder (io.mycat.beans.mycat.ResultSetBuilder)3 ColumnDefPacket (io.mycat.beans.mysql.packet.ColumnDefPacket)3 ColumnDescriptor (io.vertx.sqlclient.desc.ColumnDescriptor)3 MycatMySQLRowMetaData (io.mycat.beans.mycat.MycatMySQLRowMetaData)2 MycatRelDataType (io.mycat.beans.mycat.MycatRelDataType)2 MycatRowMetaData (io.mycat.beans.mycat.MycatRowMetaData)2 MySQLRowImpl (io.vertx.mysqlclient.impl.MySQLRowImpl)2 io.vertx.sqlclient (io.vertx.sqlclient)2 Row (io.vertx.sqlclient.Row)2 Duration (java.time.Duration)2 Function (java.util.function.Function)2 JdbcFieldInfo (org.apache.arrow.adapter.jdbc.JdbcFieldInfo)2 JdbcToArrowConfig (org.apache.arrow.adapter.jdbc.JdbcToArrowConfig)2 JdbcToArrowConfigBuilder (org.apache.arrow.adapter.jdbc.JdbcToArrowConfigBuilder)2 org.apache.arrow.vector (org.apache.arrow.vector)2