Esempio n. 1
0
        private void OpenExistingTable()
        {
            // Attempt to read table data.
            _tableHeaderStorage.Open();
            _logsStorage.Open();
            _logsDataStorage.Open();
            _categoriesStorage.Open();

            _tableHeaderStorage.ReadStructure(ref _tableHeaderStructure);

            // Load categories.
            var oneCategoryEntry = default(RaxCategoryEntry);

            for (int i = 0; i < _tableHeaderStructure.CategoriesCount; i++)
            {
                var category = new CategoryInformation();

                _categoriesStorage.SetPositionOffset(i * _catSize);
                _categoriesStorage.ReadStructure(ref oneCategoryEntry);

                category.CategoryIndex = i;
                category.CategoryName  = new string(oneCategoryEntry.CategoryName, 0, oneCategoryEntry.CategoryRealNameLengthInBytes / 2);
                category.LogsCount     = oneCategoryEntry.Header.LogsCountInCategory;
                category.MinTimestamp  = oneCategoryEntry.Header.MinTimestamp;
                category.MaxTimestamp  = oneCategoryEntry.Header.MaxTimestamp;

                _categoriesByIndex[category.CategoryIndex] = category;
                _categoriesByName[category.CategoryName]   = category;
            }

            // Load indexes
            for (int year = new DateTime(_tableHeaderStructure.MinTimestamp).Year;
                 year <= new DateTime(_tableHeaderStructure.MaxTimestamp).Year;
                 ++year)
            {
                GetOrCreateYearIndexStorage(year);
            }
        }
Esempio n. 2
0
        public override void Open()
        {
            _indexAndHeaderStorage.Open();
            _appendOnlyDataStorage.Open();
            _compressedStorage.Open();

            _indexAndHeaderStorage.SetPositionOffset(0);
            _indexAndHeaderStorage.ReadStructure(ref _header);

            Initialize();

            if (_header.CompressedBlocksCount > 0)
            {
                var offsetsBufferBytesCount = _header.CompressedBlocksCount * 8;
                var offsetsBuffer           = new byte[offsetsBufferBytesCount];
                _indexAndHeaderStorage.ReadStructureArray(offsetsBuffer);

                var offsets = MemoryMarshal.Cast <byte, long>(offsetsBuffer);
                for (int i = 0; i < _header.CompressedBlocksCount; i++)
                {
                    _blockOffsets.Add(offsets[i]);
                }
            }
        }