public static RecordColumn toRecordColumn()

in tablestore/src/main/java/com/alicloud/openservices/tablestore/core/protocol/PlainBufferConversion.java [52:99]


    public static RecordColumn toRecordColumn(PlainBufferCell cell) throws IOException {
        if (!cell.hasCellName()) {
            throw new IOException("The cell has no name:" + cell);
        }

        ColumnValue value = ColumnValue.INTERNAL_NULL_VALUE;
        if (cell.hasCellValue()) {
            value = cell.getCellValue();
        }

        Column column = null;

        if (cell.hasCellTimestamp()) {
            column = new Column(cell.getCellName(), value, cell.getCellTimestamp());
        } else {
            column = new Column(cell.getCellName(), value);
        }

        RecordColumn.ColumnType columnType = RecordColumn.ColumnType.PUT;

        if (!cell.hasCellType()) {
            if (!cell.hasCellValue() || !cell.hasCellTimestamp()) {
                throw new IOException("The cell should have both value and timestamp: " + cell);
            }
        } else {
            switch (cell.getCellType()) {
                case PlainBufferConsts.DELETE_ONE_VERSION:
                    if (cell.hasCellValue() || !cell.hasCellTimestamp()) {
                        throw new IOException(
                                "The cell with type DELETE_ONE_VERSION should not have value but should have timestamp: "
                                        + cell);
                    }
                    columnType = RecordColumn.ColumnType.DELETE_ONE_VERSION;
                    break;
                case PlainBufferConsts.DELETE_ALL_VERSION:
                    if (cell.hasCellValue() || cell.hasCellTimestamp()) {
                        throw new IOException(
                                "The cell with type DELETE_ALL_VERSION should not have value and timestamp: " + cell);
                    }
                    columnType = RecordColumn.ColumnType.DELETE_ALL_VERSION;
                    break;
                default:
                    throw new IOException("Unknown cell type:" + cell.getCellType());
            }
        }

        return new RecordColumn(column, columnType);
    }