コード例 #1
0
        private TableMetadata ReadTableMetadata(ref SequenceReader <byte> reader)
        {
            var numericColumnCount = ColumnTypes.Count(c => IsNumberColumn((ColumnType)c));

            var metadata = new TableMetadata();

            while (reader.Remaining > 0)
            {
                reader.TryRead(out byte filedTypeCode);

                var fieldType = (MetadataFieldType)filedTypeCode;
                var length    = reader.ReadLengthEncodedInteger();

                var subReader = new SequenceReader <byte>(reader.Sequence.Slice(reader.Consumed, length));

                try
                {
                    ReadMetadataField(ref subReader, fieldType, metadata, numericColumnCount);
                }
                finally
                {
                    reader.Advance(length);
                }
            }

            return(metadata);
        }
コード例 #2
0
        private TableMetadata ReadTableMetadata(ref SequenceReader <byte> reader)
        {
            var numericColumnCount = ColumnTypes.Count(c => IsNumberColumn((ColumnType)c));

            var metadata = new TableMetadata();

            while (reader.Remaining > 0)
            {
                reader.TryRead(out byte filedTypeCode);

                var fieldType = (MetadataFieldType)filedTypeCode;

                switch (fieldType)
                {
                case MetadataFieldType.SIGNEDNESS:
                    metadata.Signedness = reader.ReadBitArray(numericColumnCount);
                    break;

                case MetadataFieldType.DEFAULT_CHARSET:
                    metadata.DefaultCharset = ReadDefaultCharset(ref reader);
                    break;

                case MetadataFieldType.COLUMN_CHARSET:
                    metadata.ColumnCharsets = ReadIntegers(ref reader);
                    break;

                case MetadataFieldType.COLUMN_NAME:
                    metadata.ColumnNames = ReadStringList(ref reader);
                    break;

                case MetadataFieldType.SET_STR_VALUE:
                    metadata.SetStrValues = ReadTypeValues(ref reader);
                    break;

                case MetadataFieldType.ENUM_STR_VALUE:
                    metadata.EnumStrValues = ReadTypeValues(ref reader);
                    break;

                case MetadataFieldType.GEOMETRY_TYPE:
                    metadata.GeometryTypes = ReadIntegers(ref reader);
                    break;

                case MetadataFieldType.SIMPLE_PRIMARY_KEY:
                    metadata.SimplePrimaryKeys = ReadIntegers(ref reader);
                    break;

                case MetadataFieldType.PRIMARY_KEY_WITH_PREFIX:
                    metadata.PrimaryKeysWithPrefix = ReadIntegerDictionary(ref reader);
                    break;

                case MetadataFieldType.ENUM_AND_SET_DEFAULT_CHARSET:
                    metadata.EnumAndSetDefaultCharset = ReadDefaultCharset(ref reader);
                    break;

                case MetadataFieldType.ENUM_AND_SET_COLUMN_CHARSET:
                    metadata.EnumAndSetColumnCharsets = ReadIntegers(ref reader);
                    break;

                default:
                    throw new Exception("Unsupported table metadata field type: " + fieldType);
                }
            }

            return(metadata);
        }