Exemplo n.º 1
0
        /// <summary>
        /// The recursive portion of the find key algorithm invoked by the FindKey method of the parent Index.
        /// </summary>
        public bool FindKey(Schema.IRowType keyRowType, NativeRow key, RowTreeSearchPath rowTreeSearchPath, out int entryNumber)
        {
            rowTreeSearchPath.Add(this);
            if (Node.NodeType == NativeRowTreeNodeType.Routing)
            {
                // Perform a binary search among the keys in this node to determine which streamid to follow for the next node
                bool result = NodeSearch(keyRowType, key, out entryNumber);

                // If the key was found, use the given entry number, otherwise, use the one before the given entry
                entryNumber = result ? entryNumber : (entryNumber - 1);
                return
                    (new RowTreeNode
                     (
                         Manager,
                         Tree,
                         RoutingNode.Nodes[entryNumber],
                         LockMode.Shared
                     ).FindKey
                     (
                         keyRowType,
                         key,
                         rowTreeSearchPath,
                         out entryNumber
                     ));
            }
            else
            {
                // Perform a binary search among the keys in this node to determine which entry, if any, is equal to the given key
                return(NodeSearch(keyRowType, key, out entryNumber));
            }
        }