예제 #1
0
        private void OpenInternal(Transaction transaction)
        {
            var fileTree = transaction.ReadTree(_tree);

            if (fileTree == null)
            {
                throw new FileNotFoundException($"Could not find '{_tree}' tree for index input", _name);
            }

            using (Slice.From(transaction.Allocator, _name, out Slice fileName))
            {
                _stream = fileTree.ReadStream(fileName);
                if (_stream == null)
                {
                    throw new FileNotFoundException("Could not find index input", _name);
                }
            }
        }
예제 #2
0
        private void OpenInternal(Transaction transaction)
        {
            if (transaction.IsWriteTransaction == false)
            {
                if (transaction.LowLevelTransaction.ImmutableExternalState is IndexTransactionCache cache)
                {
                    if (cache.DirectoriesByName.TryGetValue(_directory.Name, out var files))
                    {
                        if (files.ChunksByName.TryGetValue(_name, out var details))
                        {
                            // we don't dispose here explicitly, the fileName needs to be
                            // alive as long as the transaction is
                            Slice.From(transaction.Allocator, _name, out Slice fileName);
                            _stream = new VoronStream(fileName, details, transaction.LowLevelTransaction);
                            return;
                        }
                    }
                }
            }

            var fileTree = transaction.ReadTree(_tree);

            if (fileTree == null)
            {
                throw new FileNotFoundException($"Could not find '{_tree}' tree for index input", _name);
            }

            using (Slice.From(transaction.Allocator, _name, out Slice fileName))
            {
                _stream = fileTree.ReadStream(fileName);
                if (_stream == null)
                {
                    throw new FileNotFoundException("Could not find index input", _name);
                }
            }
        }