Exemplo n.º 1
0
        /// <summary>
        /// Get a exist collection. Returns null if not exists
        /// </summary>
        public CollectionPage Get(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var header = _pager.GetPage <HeaderPage>(0);

            uint pageID;

            if (header.CollectionPages.TryGetValue(name, out pageID))
            {
                return(_pager.GetPage <CollectionPage>(pageID));
            }

            throw new Exception("Collection not found: " + name);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get a node inside a page using PageAddress - Returns null if address IsEmpty
        /// </summary>
        public IndexNode GetNode(LiteDB.PageAddress address)
        {
            if (address.IsEmpty)
            {
                return(null);
            }
            var page = _pager.GetPage <IndexPage>(address.PageID);

            return(page.Nodes[address.Index]);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get all collections names from header
        /// </summary>
        public IEnumerable <string> GetCollections()
        {
            var header = _pager.GetPage <HeaderPage>(0);

            return(header.CollectionPages.Keys);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get a data block from a DataPage using address
        /// </summary>
        public DataBlock GetBlock(PageAddress blockAddress)
        {
            var page = _pager.GetPage <DataPage>(blockAddress.PageID);

            return(page.DataBlocks[blockAddress.Index]);
        }