Example #1
0
		public Slice(SliceOptions options)
		{
			Options = options;
			_pointer = null;
			_array = null;
			_size = 0;
		}
Example #2
0
		public Slice(byte* key, ushort size)
		{
			_size = size;
			Options = SliceOptions.Key;
			_array = null;
			_pointer = key;
		}
Example #3
0
		public Slice(byte[] key, ushort size)
		{
			if (key == null) throw new ArgumentNullException("key");
			_size = size;
			Options = SliceOptions.Key;
			_pointer = null;
			_array = key;
		}
Example #4
0
		public Slice(byte[] key)
		{
			if (key == null) throw new ArgumentNullException("key");
			_pointerSize = 0;
			Options = SliceOptions.Key;
			_pointer = null;
			_array = key;
		}
Example #5
0
		public Slice(SliceOptions options)
		{
			Options = options;
			Pointer = null;
			Array = null;
			Size = 0;
			KeyLength = 0;
		}
Example #6
0
 protected MemorySlice(SliceOptions options)
 {
     this.Options = options;
 }
Example #7
0
		public Slice(SliceOptions options) : base( options )
		{}
Example #8
0
		public Slice(NodeHeader* node)
		{
			Options = SliceOptions.Key;
			Set(node);
		}
Example #9
0
 public Slice(SliceOptions options) : base(options)
 {
 }
Example #10
0
 protected MemorySlice(SliceOptions options, ushort size, ushort keyLength)
 {
     this.Options   = options;
     this.Size      = size;
     this.KeyLength = keyLength;
 }
Example #11
0
 protected MemorySlice(SliceOptions options)
 {
     this.Options = options;
 }
Example #12
0
 public Slice(NodeHeader *node)
 {
     Options = SliceOptions.Key;
     Set(node);
 }
Example #13
0
        public TreeNodeHeader *Original_WithPrefetch_Search(TreePage page, ByteStringContext allocator, Slice key)
        {
            int numberOfEntries = page.NumberOfEntries;

            if (numberOfEntries == 0)
            {
                goto NoEntries;
            }

            int lastMatch          = -1;
            int lastSearchPosition = 0;

            SliceOptions options = key.Options;

            if (options == SliceOptions.Key)
            {
                if (numberOfEntries == 1)
                {
                    goto SingleEntryKey;
                }

                int low      = page.IsLeaf ? 0 : 1;
                int high     = numberOfEntries - 1;
                int position = 0;

                ushort *offsets = page.KeysOffsets;
                byte *  @base   = page.Base;
                while (low <= high)
                {
                    position = (low + high) >> 1;

                    var node = (TreeNodeHeader *)(@base + offsets[position]);

                    Slice pageKey;
                    using (TreeNodeHeader.ToSlicePtr(allocator, node, out pageKey))
                    {
                        Sse.Prefetch0(pageKey.Content.Ptr);
                        lastMatch = SliceComparer.CompareInline(key, pageKey);
                    }

                    if (lastMatch == 0)
                    {
                        break;
                    }

                    if (lastMatch > 0)
                    {
                        low = position + 1;
                    }
                    else
                    {
                        high = position - 1;
                    }
                }

                if (lastMatch > 0) // found entry less than key
                {
                    position++;    // move to the smallest entry larger than the key
                }

                lastSearchPosition = position;
                goto MultipleEntryKey;
            }
            if (options == SliceOptions.BeforeAllKeys)
            {
                lastMatch = 1;
                goto MultipleEntryKey;
            }
            if (options == SliceOptions.AfterAllKeys)
            {
                lastSearchPosition = numberOfEntries - 1;
                goto MultipleEntryKey;
            }

            return(null);

NoEntries:
            {
                page.LastSearchPosition = 0;
                page.LastMatch          = 1;
                return(null);
            }

SingleEntryKey:
            {
                var node = page.GetNode(0);

                Slice pageKey;
                using (TreeNodeHeader.ToSlicePtr(allocator, node, out pageKey))
                {
                    page.LastMatch = SliceComparer.CompareInline(key, pageKey);
                }

                page.LastSearchPosition = page.LastMatch > 0 ? 1 : 0;
                return(page.LastSearchPosition == 0 ? node : null);
            }

MultipleEntryKey:
            {
                page.LastMatch          = lastMatch;
                page.LastSearchPosition = lastSearchPosition;

                if (lastSearchPosition >= numberOfEntries)
                {
                    return(null);
                }

                return(page.GetNode(lastSearchPosition));
            }
        }
Example #14
0
 public Slice(SliceOptions options, ByteString content)
 {
     Content = content;
     Content.SetUserDefinedFlags((ByteStringType)options);
 }
Example #15
0
 protected MemorySlice(SliceOptions options, ushort size, ushort keyLength)
 {
     this.Options = options;
     this.Size = size;
     this.KeyLength = keyLength;
 }
Example #16
0
 public PrefixedSlice(SliceOptions options)
     : this()
 {
     Options = options;
 }
Example #17
0
 public PrefixedSlice(SliceOptions options)
     : this()
 {
     Options = options;
 }