Search in sources :

Example 1 with IndexInfo

use of com.pingcap.tidb.tipb.IndexInfo in project tispark by pingcap.

the class TiIndexInfo method toProto.

public IndexInfo toProto(TiTableInfo tableInfo) {
    IndexInfo.Builder builder = IndexInfo.newBuilder().setTableId(tableInfo.getId()).setIndexId(id).setUnique(isUnique);
    List<TiColumnInfo> columns = tableInfo.getColumns();
    for (TiIndexColumn indexColumn : getIndexColumns()) {
        int offset = indexColumn.getOffset();
        TiColumnInfo column = columns.get(offset);
        builder.addColumns(column.toProto(tableInfo));
    }
    if (tableInfo.isPkHandle()) {
        for (TiColumnInfo column : columns) {
            if (!column.isPrimaryKey()) {
                continue;
            }
            ColumnInfo pbColumn = column.toProto(tableInfo);
            builder.addColumns(pbColumn);
        }
    }
    return builder.build();
}
Also used : ColumnInfo(com.pingcap.tidb.tipb.ColumnInfo) IndexInfo(com.pingcap.tidb.tipb.IndexInfo)

Example 2 with IndexInfo

use of com.pingcap.tidb.tipb.IndexInfo in project client-java by tikv.

the class TiIndexInfo method toProto.

public IndexInfo toProto(TiTableInfo tableInfo) {
    IndexInfo.Builder builder = IndexInfo.newBuilder().setTableId(tableInfo.getId()).setIndexId(id).setUnique(isUnique);
    List<org.tikv.common.meta.TiColumnInfo> columns = tableInfo.getColumns();
    for (TiIndexColumn indexColumn : getIndexColumns()) {
        int offset = indexColumn.getOffset();
        org.tikv.common.meta.TiColumnInfo column = columns.get(offset);
        builder.addColumns(column.toProto(tableInfo));
    }
    if (tableInfo.isPkHandle()) {
        for (org.tikv.common.meta.TiColumnInfo column : columns) {
            if (!column.isPrimaryKey()) {
                continue;
            }
            ColumnInfo pbColumn = column.toProto(tableInfo);
            builder.addColumns(pbColumn);
        }
    }
    return builder.build();
}
Also used : ColumnInfo(com.pingcap.tidb.tipb.ColumnInfo) IndexInfo(com.pingcap.tidb.tipb.IndexInfo)

Aggregations

ColumnInfo (com.pingcap.tidb.tipb.ColumnInfo)2 IndexInfo (com.pingcap.tidb.tipb.IndexInfo)2