Exemplo n.º 1
0
        public override NodeAVL SetParent(IPersistentStore store, NodeAVL n)
        {
            NodeAVLDisk node = this;
            RowAVLDisk  row  = this.row;

            if (!row.KeepInMemory(true))
            {
                row  = (RowAVLDisk)store.Get(this.row, true);
                node = (NodeAVLDisk)row.GetNode(this._iId);
            }
            if (!row.IsInMemory())
            {
                row.KeepInMemory(false);
                throw Error.RuntimeError(0xc9, "NodeAVLDisk");
            }
            row.SetNodesChanged();
            node._iParent = (n == null) ? -1 : n.GetPos();
            if ((n != null) && !n.IsInMemory())
            {
                n = this.FindNode(store, n.GetPos());
            }
            node.nParent = n;
            row.KeepInMemory(false);
            return(node);
        }
Exemplo n.º 2
0
 public NodeAVLDisk(RowAVLDisk r, IRowInputInterface input, int id)
 {
     this._iLeft   = -1;
     this._iParent = -1;
     this._iRight  = -1;
     this.row      = r;
     this._iId     = id;
     this.iData    = r.GetPos();
     base.IBalance = input.ReadInt();
     this._iLeft   = input.ReadInt();
     if (this._iLeft <= 0)
     {
         this._iLeft = -1;
     }
     this._iRight = input.ReadInt();
     if (this._iRight <= 0)
     {
         this._iRight = -1;
     }
     this._iParent = input.ReadInt();
     if (this._iParent <= 0)
     {
         this._iParent = -1;
     }
 }
Exemplo n.º 3
0
        public override void Replace(IPersistentStore store, Index index, NodeAVL n)
        {
            NodeAVLDisk node = this;
            RowAVLDisk  row  = this.row;

            if (!row.KeepInMemory(true))
            {
                row  = (RowAVLDisk)store.Get(this.row, true);
                node = (NodeAVLDisk)row.GetNode(this._iId);
            }
            if (node._iParent == -1)
            {
                if (n != null)
                {
                    n = n.SetParent(store, null);
                }
                store.SetAccessor(index, n);
            }
            else
            {
                bool isLeft = node.IsFromLeft(store);
                node.GetParent(store).Set(store, isLeft, n);
            }
            row.KeepInMemory(false);
        }
Exemplo n.º 4
0
        public override Row GetNewCachedObject(Session session, object obj)
        {
            int num2 = this._rowIdSequence;

            this._rowIdSequence = num2 + 1;
            int position = num2;

            if (this._isCached)
            {
                Row row2 = new RowAVLDisk(base.table, (object[])obj);
                this.Add(row2);
                if (this._isTempTable)
                {
                    RowAction.AddInsertAction(session, base.table, row2);
                }
                return(row2);
            }
            this._memoryRowCount++;
            if (this._useCache && (this._memoryRowCount > this._maxMemoryRowCount))
            {
                this.ChangeToDiskTable();
                return(this.GetNewCachedObject(session, obj));
            }
            RowAVL row = new RowAVL(base.table, (object[])obj, position);

            row.SetNewNodes();
            if (this._isTempTable)
            {
                RowAction action = new RowAction(session, base.table, 1, row, null);
                row.rowAction = action;
            }
            return(row);
        }
Exemplo n.º 5
0
 public NodeAVLDisk(RowAVLDisk r, int id)
 {
     this._iLeft   = -1;
     this._iParent = -1;
     this._iRight  = -1;
     this.row      = r;
     this._iId     = id;
     this.iData    = r.GetPos();
 }
Exemplo n.º 6
0
        private NodeAVLDisk FindNode(IPersistentStore store, int pos)
        {
            NodeAVLDisk node  = null;
            RowAVLDisk  disk2 = (RowAVLDisk)store.Get(pos, false);

            if (disk2 != null)
            {
                node = (NodeAVLDisk)disk2.GetNode(this._iId);
            }
            return(node);
        }
Exemplo n.º 7
0
        public override Row GetNewCachedObject(Session session, object obj)
        {
            RowAVL wavl = new RowAVLDisk(base.table, (object[])obj);

            this.Add(wavl);
            if (session != null)
            {
                RowAction action = new RowAction(session, base.table, 1, wavl, null);
                wavl.rowAction = action;
            }
            return(wavl);
        }
Exemplo n.º 8
0
        public override ICachedObject Get(IRowInputInterface input)
        {
            ICachedObject obj2;

            try
            {
                obj2 = new RowAVLDisk(base.table, input);
            }
            catch (IOException exception)
            {
                throw Error.GetError(0x1d2, exception);
            }
            return(obj2);
        }
Exemplo n.º 9
0
        public override NodeAVL SetBalance(IPersistentStore store, int b)
        {
            NodeAVLDisk node = this;
            RowAVLDisk  row  = this.row;

            if (!row.KeepInMemory(true))
            {
                row  = (RowAVLDisk)store.Get(this.row, true);
                node = (NodeAVLDisk)row.GetNode(this._iId);
            }
            if (!row.IsInMemory())
            {
                throw Error.RuntimeError(0xc9, "NodeAVLDisk");
            }
            row.SetNodesChanged();
            node.IBalance = b;
            row.KeepInMemory(false);
            return(node);
        }