Beispiel #1
0
    public static ColumnSchema FromProtobuf(ColumnSchemaPB columnSchemaPb)
    {
        var type           = (KuduType)columnSchemaPb.Type;
        var typeAttributes = columnSchemaPb.TypeAttributes.ToTypeAttributes();
        var defaultValue   = columnSchemaPb.HasWriteDefaultValue
            ? KuduEncoder.DecodeDefaultValue(
            type, typeAttributes, columnSchemaPb.WriteDefaultValue.Span)
            : null;

        return(new ColumnSchema(
                   columnSchemaPb.Name,
                   type,
                   columnSchemaPb.IsKey,
                   columnSchemaPb.IsNullable,
                   defaultValue,
                   columnSchemaPb.CfileBlockSize,
                   (EncodingType)columnSchemaPb.Encoding,
                   (CompressionType)columnSchemaPb.Compression,
                   typeAttributes,
                   columnSchemaPb.Comment));
    }
Beispiel #2
0
    private static ColumnSchemaPB ToColumnSchemaPb(
        ColumnSchema columnSchema, bool isDeleted)
    {
        var type = isDeleted
            ? DataType.IsDeleted
            : (DataType)columnSchema.Type;

        var columnSchemaPb = new ColumnSchemaPB
        {
            Name       = columnSchema.Name,
            Type       = type,
            IsNullable = columnSchema.IsNullable,
            // Set isKey to false on the passed ColumnSchema.
            // This allows out of order key columns in projections.
            IsKey          = false,
            TypeAttributes = columnSchema.TypeAttributes.ToTypeAttributesPb()
        };

        ProtobufHelper.CopyDefaultValueToPb(columnSchema, columnSchemaPb);

        return(columnSchemaPb);
    }