Exemplo n.º 1
0
        private bool FindIndexKey(Schema.IRowType keyRowType, NativeRow key, out RowTreeNode indexNode, out int entryNumber)
        {
            RowTreeSearchPath searchPath = new RowTreeSearchPath();

            try
            {
                bool result = _accessPath.FindKey(_manager, keyRowType, key, searchPath, out entryNumber);
                indexNode = searchPath.DisownAt(searchPath.Count - 1);
                return(result);
            }
            finally
            {
                searchPath.Dispose();
            }
        }
Exemplo n.º 2
0
        /// <summary>Updates the entry given by AOldKey to the entry given by ANewKey and ANewData.  If AOldKey == ANewKey, the data for the entry is updated in place, otherwise it is moved to the location given by ANewKey.</summary>
        public override void Update(IValueManager manager, NativeRow oldKey, NativeRow newKey, NativeRow newData)
        {
            int entryNumber;

            using (RowTreeSearchPath rowTreeSearchPath = new RowTreeSearchPath())
            {
                bool result = FindKey(manager, KeyRowType, oldKey, rowTreeSearchPath, out entryNumber);
                if (!result)
                {
                    throw new IndexException(IndexException.Codes.KeyNotFound);
                }

                if (Compare(manager, KeyRowType, oldKey, KeyRowType, newKey) == 0)
                {
                    if (newData != null)
                    {
                        rowTreeSearchPath.DataNode.UpdateData(newData, entryNumber);
                    }
                }
                else
                {
                    if (newData == null)
                    {
                        newData = rowTreeSearchPath.DataNode.DataNode.Rows[entryNumber];
                        rowTreeSearchPath.DataNode.DataNode.Delete(entryNumber);                         // Don't dispose here this is a move
                    }
                    else
                    {
                        InternalDelete(manager, rowTreeSearchPath, entryNumber);                         // Dispose here this is not a move
                    }
                    rowTreeSearchPath.Dispose();
                    result = FindKey(manager, KeyRowType, newKey, rowTreeSearchPath, out entryNumber);
                    if (result)
                    {
                        throw new IndexException(IndexException.Codes.DuplicateKey);
                    }

                    InternalInsert(manager, rowTreeSearchPath, entryNumber, newKey, newData);
                }
            }
        }