当前位置: 首页>>代码示例>>C#>>正文


C# Trees.NodeHeader类代码示例

本文整理汇总了C#中Voron.Trees.NodeHeader的典型用法代码示例。如果您正苦于以下问题:C# NodeHeader类的具体用法?C# NodeHeader怎么用?C# NodeHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NodeHeader类属于Voron.Trees命名空间,在下文中一共展示了NodeHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetInline

 public static void SetInline(Slice slice, NodeHeader* node)
 {
     slice.Pointer = (byte*)node + Constants.NodeHeaderSize;
     slice.Size = node->KeySize;
     slice.KeyLength = node->KeySize;
     slice.Array = null;
 }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:7,代码来源:Slice.cs

示例2: CopyTo

 public static void CopyTo(Transaction tx, NodeHeader* node, byte* dest)
 {
     if (node->Flags == (NodeFlags.PageRef))
     {
         var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
         Memory.Copy(dest, overFlowPage.Base + Constants.PageHeaderSize, overFlowPage.OverflowSize);
     }
     Memory.Copy(dest, (byte*)node + node->KeySize + Constants.NodeHeaderSize, node->DataSize);
 }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:9,代码来源:NodeHeader.cs

示例3: DirectAccess

 public static byte* DirectAccess(Transaction tx, NodeHeader* node)
 {
     if (node->Flags == (NodeFlags.PageRef))
     {
         var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
         return overFlowPage.Base + Constants.PageHeaderSize;
     }
     return (byte*) node + node->KeySize + Constants.NodeHeaderSize;
 }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:9,代码来源:NodeHeader.cs

示例4: GetDataSize

 public static int GetDataSize(Transaction tx, NodeHeader* node)
 {
     if (node->Flags == (NodeFlags.PageRef))
     {
         var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
         return overFlowPage.OverflowSize;
     }
     return node->DataSize;
 }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:9,代码来源:NodeHeader.cs

示例5: Reader

        public unsafe static ValueReader Reader(Transaction tx, NodeHeader* node)
		{
			if (node->Flags == (NodeFlags.PageRef))
			{
				var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
                return new ValueReader(overFlowPage.Base + Constants.PageHeaderSize, overFlowPage.OverflowSize);
			}
            return new ValueReader((byte*)node + node->KeySize + Constants.NodeHeaderSize, node->DataSize);
		}
开发者ID:randacc,项目名称:ravendb,代码行数:9,代码来源:NodeHeader.cs

示例6: NodeEntry

        public static int NodeEntry(NodeHeader* other)
        {
            var sz = other->KeySize + Constants.NodeHeaderSize;
            if (other->Flags == NodeFlags.Data || other->Flags == NodeFlags.MultiValuePageRef)
                sz += other->DataSize;

            sz += sz & 1;

            return sz;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:10,代码来源:SizeOf.cs

示例7: GetData

 public static Slice GetData(Transaction tx, NodeHeader* node)
 {
     if (node->Flags == (NodeFlags.PageRef))
     {
         var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
         if (overFlowPage.OverflowSize > ushort.MaxValue)
             throw new InvalidOperationException("Cannot convert big data to a slice, too big");
         return new Slice(overFlowPage.Base + Constants.PageHeaderSize, (ushort)overFlowPage.OverflowSize);
     }
     return new Slice((byte*)node + node->KeySize + Constants.NodeHeaderSize, (ushort) node->DataSize);
 }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:11,代码来源:NodeHeader.cs

示例8: NodeEntryWithAnotherKey

        public static int NodeEntryWithAnotherKey(NodeHeader* other, Slice key)
        {
            var keySize = key == null ? other->KeySize : key.Size;
            var sz = keySize + Constants.NodeHeaderSize;
            if (other->Flags == NodeFlags.Data || other->Flags == NodeFlags.MultiValuePageRef)
                sz += other->DataSize;

            sz += sz & 1;

            return sz;
        }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:11,代码来源:SizeOf.cs

示例9: Reader

        public static ValueReader Reader(Transaction tx, NodeHeader* node)
        {
            if (node->Flags == (NodeFlags.PageRef))
            {
                var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);

                Debug.Assert(overFlowPage.IsOverflow, "Requested oveflow page but got " + overFlowPage.Flags);
                Debug.Assert(overFlowPage.OverflowSize > 0, "Overflow page cannot be size equal 0 bytes");

                return new ValueReader(overFlowPage.Base + Constants.PageHeaderSize, overFlowPage.OverflowSize);
            }
            return new ValueReader((byte*)node + node->KeySize + Constants.NodeHeaderSize, node->DataSize);
        }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:13,代码来源:NodeHeader.cs

示例10: PrefixedSlice

		public PrefixedSlice(NodeHeader* node)
		{
			if (node->KeySize > 0)
			{
				var prefixHeaderPtr = (PrefixedSliceHeader*)((byte*)node + Constants.NodeHeaderSize);
				Header = *prefixHeaderPtr;

				NonPrefixedData = new Slice((byte*)prefixHeaderPtr + Constants.PrefixedSliceHeaderSize, Header.NonPrefixedDataSize);

				Size = node->KeySize;
				KeyLength = (ushort) (Header.PrefixUsage + Header.NonPrefixedDataSize);
			}
			else
			{
				Size = 0;
				KeyLength = 0;
			}

			Options = SliceOptions.Key;
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:20,代码来源:PrefixedSlice.cs

示例11: Set

		public void Set(NodeHeader* node)
		{
			Set((byte*)node + Constants.NodeHeaderSize, node->KeySize);
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:4,代码来源:Slice.cs

示例12: ValidateCurrentKey

		public unsafe static bool ValidateCurrentKey(this IIterator self, NodeHeader* node)
		{
			if (self.RequiredPrefix != null)
			{
				var currentKey = new Slice(node);
				if (currentKey.StartsWith(self.RequiredPrefix) == false)
					return false;
			}
			if (self.MaxKey != null)
			{
				var currentKey = new Slice(node);
				if (currentKey.Compare(self.MaxKey) >= 0)
					return false;
			}
			return true;
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:16,代码来源:TreeIterator.cs

示例13: GetNodeKey

        public MemorySlice GetNodeKey(NodeHeader* node)
        {
            if (KeysPrefixed == false)
            {
                var keySize = node->KeySize;
                var key = new byte[keySize];

                fixed (byte* ptr = key)
                    Memory.CopyInline(ptr, (byte*)node + Constants.NodeHeaderSize, keySize);

                return new Slice(key);
            }

            if (node->KeySize == 0)
                return new PrefixedSlice(Slice.Empty);

            var prefixHeader = (PrefixedSliceHeader*)((byte*)node + Constants.NodeHeaderSize);

            var nonPrefixedSize = prefixHeader->NonPrefixedDataSize;
            var nonPrefixedData = new byte[nonPrefixedSize];

            fixed (byte* ptr = nonPrefixedData)
                Memory.CopyInline(ptr, (byte*)prefixHeader + Constants.PrefixedSliceHeaderSize, nonPrefixedSize);

            var prefixedSlice = new PrefixedSlice(prefixHeader->PrefixId, prefixHeader->PrefixUsage, new Slice(nonPrefixedData));

            if (prefixHeader->PrefixId == PrefixedSlice.NonPrefixedId)
                return prefixedSlice;

            AssertPrefixNode(prefixedSlice.Header.PrefixId);

            var prefixNodePtr = (PrefixNodeHeader*) (_base + _prefixSection->PrefixOffsets[prefixedSlice.Header.PrefixId]);

            var prefixLength = prefixNodePtr->PrefixLength;
            var prefixData = new byte[prefixLength];

            fixed (byte* ptr = prefixData)
                Memory.CopyInline(ptr, (byte*)prefixNodePtr + Constants.PrefixNodeHeaderSize, prefixLength);

            prefixedSlice.Prefix = new PrefixNode(new PrefixNodeHeader{ PrefixLength =  prefixLength }, prefixData, PageNumber);

            return prefixedSlice;
        }
开发者ID:ricardobrandao,项目名称:ravendb,代码行数:43,代码来源:Page.cs

示例14: SetNodeKey

 // REVIEW: Removed forced inlining for now until we can see if we improve without needing it. 
 // [MethodImpl(MethodImplOptions.AggressiveInlining)]
 public void SetNodeKey(NodeHeader* node, ref MemorySlice sliceInstance)
 {
     if (KeysPrefixed)
     {
         var slice = (PrefixedSlice)sliceInstance;
         SetNodeKey(node, ref slice);
         sliceInstance = slice;
     }                
     else
     {
         Slice slice = (Slice)sliceInstance;
         SetNodeKey(node, ref slice);
         sliceInstance = slice;
     }
 }
开发者ID:ricardobrandao,项目名称:ravendb,代码行数:17,代码来源:Page.cs

示例15: TryOverwriteOverflowPages

		private bool TryOverwriteOverflowPages(Transaction tx, TreeMutableState treeState, NodeHeader* updatedNode,
													  Slice key, int len, ushort? version, out byte* pos)
		{
			if (updatedNode->Flags == NodeFlags.PageRef &&
				tx.Id <= tx.Environment.OldestTransaction) // ensure MVCC - do not overwrite if there is some older active transaction that might read those overflows
			{
				var overflowPage = tx.GetReadOnlyPage(updatedNode->PageNumber);

				if (len <= overflowPage.OverflowSize)
				{
					CheckConcurrency(key, version, updatedNode->Version, TreeActionType.Add);

					if (updatedNode->Version == ushort.MaxValue)
						updatedNode->Version = 0;
					updatedNode->Version++;

					var availableOverflows = tx.DataPager.GetNumberOfOverflowPages(overflowPage.OverflowSize);

					var requestedOverflows = tx.DataPager.GetNumberOfOverflowPages(len);

					var overflowsToFree = availableOverflows - requestedOverflows;

					for (int i = 0; i < overflowsToFree; i++)
					{
						tx.FreePage(overflowPage.PageNumber + requestedOverflows + i);
					}

					treeState.OverflowPages -= overflowsToFree;
					treeState.PageCount -= overflowsToFree;

					overflowPage.OverflowSize = len;

					pos = overflowPage.Base + Constants.PageHeaderSize;
					return true;
				}
			}
			pos = null;
			return false;
		}
开发者ID:paulcbetts,项目名称:ravendb,代码行数:39,代码来源:Tree.cs


注:本文中的Voron.Trees.NodeHeader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。