Наследование: ITrieRootNode
Пример #1
0
        public LTrieRow(LTrieRootNode root)
        {
            _root = root;

            this._linkToValue = root.EmptyPointer;

            TableFixTime = root.Tree.Storage.StorageFixTime;
        }
Пример #2
0
        public LTrieRow(LTrieRootNode root)
        {
            _root = root;

            this._linkToValue = root.EmptyPointer;

            TableFixTime = root.Tree.Storage.StorageFixTime;
        }
Пример #3
0
        //Format
        //TotalSize,LinkToValue,0-255 Links to Kids
        public LTrieGenerationNode(LTrieRootNode rootNode)
        {
            _root = rootNode;

            DefaultEmptyPointer = this._root.EmptyPointer;
            DefaultPointerLen = this._root.Tree.Storage.TrieSettings.POINTER_LENGTH;
            Pointer = new byte[DefaultPointerLen];

            KidsInNode = new LTrieKidsInNode(DefaultPointerLen);

            //Total length,link to value, 256* (Ptr + 1[name of kid[0-255]] + 1 (ptr to next gen or to value)
            MaximumKidLineLength = 2 + DefaultPointerLen + (256 * (DefaultPointerLen + 2));
        }
Пример #4
0
        public IEnumerable<LTrieRow> IterateBackwardSkipFrom(byte[] key, ulong skippingQuantity)
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Backward bw = new Backward(readRootNode);
            return bw.IterateBackwardSkipFrom(key, skippingQuantity,true);
        }
Пример #5
0
        public IEnumerable<LTrieRow> IterateBackwardSkip(ulong skippingQuantity, bool useCache)
        {
            this.CheckTableIsOperable();

            if (!useCache)
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();

                Backward bw = new Backward(rn);
                return bw.IterateBackwardSkip(skippingQuantity, false);

            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(this);
                Backward bw = new Backward(readRootNode);
                return bw.IterateBackwardSkip(skippingQuantity, true);
            }
        }
Пример #6
0
        public LTrieRow IterateBackwardForMaximal(bool useCache)
        {
            this.CheckTableIsOperable();

            if (!useCache)
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();

                Backward bw = new Backward(rn);
                return bw.IterateBackwardForMaximal(false);

            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(this);
                Backward bw = new Backward(readRootNode);
                return bw.IterateBackwardForMaximal(true);
            }
        }
Пример #7
0
        public LTrieRow IterateBackwardForMaximal()
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Backward bw = new Backward(readRootNode);
            return bw.IterateBackwardForMaximal(true);
        }
Пример #8
0
        public IEnumerable<LTrieRow> IterateBackward()
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Backward bw = new Backward(readRootNode);
            return bw.IterateBackward(true);
        }
Пример #9
0
        //Iterate
        public IEnumerable<LTrieRow> IterateForward()
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Forward fw = new Forward(readRootNode);
            return fw.IterateForward(true);
        }
Пример #10
0
        /// <summary>
        /// if useCache = true; uses newly created root node, else uses writing root node
        /// </summary>
        /// <returns></returns>
        public ulong Count(bool useCache)
        {
            this.CheckTableIsOperable();

            if (useCache)
            {
                LTrieRootNode readRootNode = new LTrieRootNode(this);
                return readRootNode.RecordsCount;
            }
            else
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();
                return rn.RecordsCount;
            }
        }
Пример #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="startKey"></param>
        /// <returns></returns>
        public IEnumerable<LTrieRow> IterateForwardStartsWithClosestToPrefix(byte[] startKey)
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Forward bw = new Forward(readRootNode);
            return bw.IterateForwardStartsWithClosestToPrefix(startKey, true);
        }
Пример #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="startKey"></param>
        /// <param name="useCache"></param>
        /// <returns></returns>
        public IEnumerable<LTrieRow> IterateForwardStartsWithClosestToPrefix(byte[] startKey, bool useCache)
        {
            this.CheckTableIsOperable();

            if (!useCache)
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();

                Forward bw = new Forward(rn);
                return bw.IterateForwardStartsWithClosestToPrefix(startKey, false);

            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(this);
                Forward bw = new Forward(readRootNode);
                return bw.IterateForwardStartsWithClosestToPrefix(startKey, true);
            }
        }
Пример #13
0
        //SKIP
        public IEnumerable<LTrieRow> IterateForwardSkip(ulong skippingQuantity)
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Forward bw = new Forward(readRootNode);
            return bw.IterateForwardSkip(skippingQuantity,true);
        }
Пример #14
0
        //Iterate From - To
        public IEnumerable<LTrieRow> IterateForwardFromTo(byte[] startKey, byte[] stopKey,bool includeStartKey, bool includeStopKey)
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Forward bw = new Forward(readRootNode);
            return bw.IterateForwardFromTo(startKey,stopKey,includeStartKey,includeStopKey,true);
        }
Пример #15
0
        //bool SYNCHRO_READ
        public IEnumerable<LTrieRow> IterateForward(bool useCache)
        {
            this.CheckTableIsOperable();

            if (!useCache)   //SYNCHRO_READ
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();

                Forward fw = new Forward(rn);
                return fw.IterateForward(false);

            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(this);
                Forward fw = new Forward(readRootNode);
                return fw.IterateForward(true);
            }
        }
Пример #16
0
        public IEnumerable<LTrieRow> IterateBackwardStartFrom(byte[] key, bool includeStartKey)
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);
            Backward bw = new Backward(readRootNode);
            return bw.IterateBackwardStartFrom(key, includeStartKey,true);
        }
Пример #17
0
        public IEnumerable<LTrieRow> IterateBackwardStartsWith(byte[] startKey)
        {
            this.CheckTableIsOperable();

            LTrieRootNode readRootNode = new LTrieRootNode(this);

            Backward bw = new Backward(readRootNode);
            return bw.IterateBackwardStartsWith(startKey,true);
        }
Пример #18
0
        public IEnumerable<LTrieRow> IterateBackwardStartFrom(byte[] key, bool includeStartKey, bool useCache)
        {
            this.CheckTableIsOperable();

            if (!useCache)
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();

                Backward bw = new Backward(rn);
                return bw.IterateBackwardStartFrom(key, includeStartKey, false);

            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(this);
                Backward bw = new Backward(readRootNode);
                return bw.IterateBackwardStartFrom(key, includeStartKey, true);
            }
        }
Пример #19
0
        /// <summary>
        /// Interface function which recreates every time new rootNode from itself by every new function call.
        /// and also packs root node last fixation dateTime (ROLL or COMMIT).
        /// It will be used for READ FUNC's via Transaction, they can decide if to create new instance of read root or use existing.
        /// Returns NULL is !TableIsOperable.
        /// </summary>
        /// <param name="modifiedDt"></param>
        /// <returns></returns>
        public ITrieRootNode GetTrieReadNode(out long dtTableFixed)
        {
            dtTableFixed = DtTableFixed;

            if (!TableIsOperable)
                return null;

            LTrieRootNode readRootNode = new LTrieRootNode(this);
            return readRootNode;
        }
Пример #20
0
        /// <summary>
        /// if useCache = true; uses newly created root node, else uses writing root node
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public LTrieRow GetKey(byte[] key,bool useCache)
        {
            this.CheckTableIsOperable();

            if (useCache)
            {
                //Creating new Root -
                LTrieRootNode readRootNode = new LTrieRootNode(this);

                return readRootNode.GetKey(key, true);
            }
            else
            {
                //Flashing changes on the disk before commit. In case if the same thread uses the same root node
                this.SaveGenerationMap();

                return rn.GetKey(key, false);
            }
        }
Пример #21
0
        /// <summary>
        /// Liana Trie
        /// </summary>
        /// <param name="storage"></param>
        public LTrie(IStorage storage)
        {
            Storage = storage;

            try
            {
                //Will instantiate also RollerBack
                Cache = new LTrieWriteCache(this);

                //If first reading or writing of root node fails also bring to exception
                rn = new LTrieRootNode(this);

                //rollBackFileName = Cache.RollBackFileName;
            }
            catch (Exception ex)
            {
                //lock (lock_TableIsOperatable)
                TableIsOperable = false;

                 throw new Exception(String.Format("LTrie init failed: {0}; Exception: {1}", this.TableName, ex.ToString()));
            }
        }