Beispiel #1
0
        internal JournalMetadata(JournalElement config, ISerializerFactory serializerFactory, Type itemType)
        {
            _serializerFactory = serializerFactory;
            var columnSerializers = _serializerFactory.Initialize(itemType);

            columnSerializers = CheckColumnMatch(config, columnSerializers, itemType);
            _columns          = ParseColumns(columnSerializers, config.Columns);
            _settings         = new JournalSettings(config, _columns);

            // Parse.
            FileCount = CalcFilesCount(_columns);

            // Timestamp.
            if (!string.IsNullOrEmpty(config.TimestampColumn))
            {
                var timestampColumn = _columns.FirstOrDefault(c =>
                                                              c.PropertyName.Equals(config.TimestampColumn, StringComparison.OrdinalIgnoreCase));

                if (timestampColumn == null)
                {
                    throw new NFSdbConfigurationException("Timestamp column with name {0} is not found",
                                                          config.TimestampColumn);
                }

                if (timestampColumn.ColumnType != EFieldType.DateTime &&
                    timestampColumn.ColumnType != EFieldType.DateTimeEpochMs &&
                    timestampColumn.ColumnType != EFieldType.Int64)
                {
                    throw new NFSdbConfigurationException("Timestamp column {0} must be DateTime or Int64 but was {1}",
                                                          config.TimestampColumn, timestampColumn.ColumnType);
                }

                _timestampColumn  = _columns.Single(c => c.FileName.Equals(config.TimestampColumn, StringComparison.OrdinalIgnoreCase));
                TimestampColumnID = _timestampColumn.ColumnID;
            }

            // IsNull.
            var last = _columns.Last();

            if (last.ColumnType == EFieldType.BitSet)
            {
                IsNullColumnID = last.ColumnID;
            }

            // Misc.
            PartitionTtl = TimeSpan.FromMilliseconds(config.OpenPartitionTtl);
            Name         = config.Class;
        }