コード例 #1
0
ファイル: Node'1.cs プロジェクト: yuwenpeng/openHistorian
 /// <summary>
 /// Sets the node data to the following node index.
 /// The node must be initialized before calling this method.
 /// </summary>
 /// <param name="nodeIndex"></param>
 public void SetNodeIndex(uint nodeIndex)
 {
     if (nodeIndex == uint.MaxValue)
     {
         throw new Exception("Invalid Node Index");
     }
     if (m_nodeIndex != nodeIndex)
     {
         if (NodeIndexChanged != null)
         {
             NodeIndexChanged(this, EventArgs.Empty);
         }
         m_nodeIndex           = nodeIndex;
         m_pointerReadVersion  = -1;
         m_pointerWriteVersion = -1;
         byte *ptr = GetReadPointer();
         if (ptr[OffsetOfNodeLevel] != Level)
         {
             throw new Exception("This node is not supposed to access the underlying node level.");
         }
         m_recordCount           = *(ushort *)(ptr + OffsetOfRecordCount);
         m_validBytes            = *(ushort *)(ptr + OffsetOfValidBytes);
         m_leftSiblingNodeIndex  = *(uint *)(ptr + OffsetOfLeftSibling);
         m_rightSiblingNodeIndex = *(uint *)(ptr + OffsetOfRightSibling);
         LowerKey.Read(ptr + OffsetOfLowerBounds);
         UpperKey.Read(ptr + OffsetOfUpperBounds);
     }
 }
コード例 #2
0
ファイル: Node'1.cs プロジェクト: yuwenpeng/openHistorian
 /// <summary>
 /// Invalidates the current node.
 /// </summary>
 public void Clear()
 {
     if (NodeIndexChanged != null)
     {
         NodeIndexChanged(this, EventArgs.Empty);
     }
     //InsideNodeBoundary = m_BoundsFalse;
     m_nodeIndex             = uint.MaxValue;
     m_pointerReadVersion    = -1;
     m_pointerWriteVersion   = -1;
     m_recordCount           = 0;
     m_validBytes            = (ushort)HeaderSize;
     m_leftSiblingNodeIndex  = uint.MaxValue;
     m_rightSiblingNodeIndex = uint.MaxValue;
     UpperKey.Clear();
     LowerKey.Clear();
 }
コード例 #3
0
        /// <summary>
        /// Splits the current node and then inserts the provided key/value into the correct node.
        /// </summary>
        private void SplitNodeThenInsert(TKey key, TValue value)
        {
            uint currentNode  = NodeIndex;
            uint newNodeIndex = m_getNextNewNodeIndex();

            TKey dividingKey = new TKey(); //m_tempKey;

            Split(newNodeIndex, dividingKey);

            SetNodeIndex(currentNode);
            if (IsKeyInsideBounds(key))
            {
                InsertUnlessFull(~GetIndexOf(key), key, value);
                UpperKey.CopyTo(dividingKey);
            }
            else
            {
                SeekToRightSibling();
                InsertUnlessFull(~GetIndexOf(key), key, value);
                LowerKey.CopyTo(dividingKey);
            }

            SparseIndex.Add(dividingKey, newNodeIndex, (byte)(Level + 1));
        }